clan::ZipArchive Class Reference - ClanLib SDK
Description: clan::ZipArchive Class Reference

Public Member Functions | List of all members
clan::ZipArchive Class Reference
clanCore I/O Data

Zip archive. More...

`#include <zip_archive.h>`

## Public Member Functions
| ZipArchive ()
| Constructs or loads a ZIP archive.
| ZipArchive (const std::string &filename)
| Constructs a ZipArchive.
| ZipArchive (const ZipArchive &copy)
| Constructs a ZipArchive.
| ZipArchive (IODevice &input)
| Constructs a ZipArchive.
| ~ZipArchive ()
void | add_file (const std::string &input_filename, const std::string &filename_in_archive)
| Adds a file to zip archive.
IODevice | create_file (const std::string &filename, bool compress=true)
| Creates a new file entry.
std::vector< ZipFileEntry > | get_file_list ()
| List of file entries in archive.
std::vector< ZipFileEntry > | get_file_list (const std::string &path)
std::string | get_pathname (const std::string &filename)
| Get full path to source:
void | load (IODevice &input)
| Loads the zip archive from a input device (done automatically at construction).
IODevice | open_file (const std::string &filename)
| Opens a file in the archive.
void | save ()
| Saves zip archive.
void | save (const std::string &filename)
| Save.
void | save (IODevice iodev)
| Save.

## Detailed Description

Zip archive.

## Constructor & Destructor Documentation

## ◆ ZipArchive() [1/4]

clan::ZipArchive::ZipArchive | ( |  | ) |

Constructs or loads a ZIP archive.

Parameters

  filename | .zip archive to load.

## ◆ ZipArchive() [2/4]

clan::ZipArchive::ZipArchive | ( | IODevice & | input | ) |

Constructs a ZipArchive.

Parameters

  input | = IODevice

## ◆ ZipArchive() [3/4]

clan::ZipArchive::ZipArchive | ( | const std::string & | filename | ) |

Constructs a ZipArchive.

Parameters

  filename | = String Ref

## ◆ ZipArchive() [4/4]

clan::ZipArchive::ZipArchive | ( | const ZipArchive & | copy | ) |

Constructs a ZipArchive.

Parameters

  copy | = Zip Archive

## ◆ ~ZipArchive()

clan::ZipArchive::~ZipArchive | ( |  | ) |

## Member Function Documentation

## ◆ add_file()

void clan::ZipArchive::add_file | ( | const std::string & | input_filename,
|  | const std::string & | filename_in_archive )

Adds a file to zip archive.

File is not added to zip file until it save() is called.

Parameters

  filename | Filename of file.

## ◆ create_file()

IODevice clan::ZipArchive::create_file | ( | const std::string & | filename,
|  | bool | compress = true )

Creates a new file entry.

## ◆ get_file_list() [1/2]

std::vector< ZipFileEntry > clan::ZipArchive::get_file_list | ( |  | ) |

List of file entries in archive.

## ◆ get_file_list() [2/2]

std::vector< ZipFileEntry > clan::ZipArchive::get_file_list | ( | const std::string & | path | ) |

## ◆ get_pathname()

std::string clan::ZipArchive::get_pathname | ( | const std::string & | filename | ) |

Get full path to source:

## ◆ load()

void clan::ZipArchive::load | ( | IODevice & | input | ) |

Loads the zip archive from a input device (done automatically at construction).

## ◆ open_file()

IODevice clan::ZipArchive::open_file | ( | const std::string & | filename | ) |

Opens a file in the archive.

## ◆ save() [1/3]

void clan::ZipArchive::save | ( |  | ) |

Saves zip archive.

Parameters

  filename | Filename of zip archive. Must not be used to save to the same as loaded from.

If no filename parameter was passed, it will modify the zip archive loaded at construction time. It does this by creating a temporary file, saving the new archive, deletes the old one and renames the temp file to the original archive filename.

If the archive was created instead of loaded, a filename must be specify a filename. Likewise, if saving to same archive as loaded from, a filename must not be specified. Doing so will cause the save operation to fail.

## ◆ save() [2/3]

void clan::ZipArchive::save | ( | const std::string & | filename | ) |

Save.

Parameters

  filename | = the filename to save to

## ◆ save() [3/3]

void clan::ZipArchive::save | ( | IODevice | iodev | ) |

Save.

Parameters

  iodev | = The file to save to

The documentation for this class was generated from the following file:

- zip_archive.h