csArchive Class Reference
This class can be used to work with standard ZIP archives. More...
#include <csutil/archive.h>
Public Member Functions | |
csArchive (const char *filename) | |
Open the archive. | |
~csArchive () | |
Close the archive. | |
void | Dir () const |
Type a directory listing of the archive to the console. | |
void * | NewFile (const char *name, size_t size=0, bool pack=true) |
Create a new file in the archive. | |
bool | DeleteFile (const char *name) |
Delete a file from the archive. | |
bool | FileExists (const char *name, size_t *size=0) const |
Return true if a path exists. | |
char * | Read (const char *name, size_t *size=0) |
Read a file completely. | |
bool | Write (void *entry, const char *data, size_t size) |
Write data to a file. | |
bool | Flush () |
Execute all pending operations involving writes to archive Neither DeleteFile or NewFile will have effect until this function will be called. | |
void * | GetFile (size_t no) |
Get Nth file in archive or 0. | |
void * | FindName (const char *name) const |
Find a file in archive; returns a handle or 0. | |
char * | GetFileName (void *entry) const |
Query name from handle. | |
size_t | GetFileSize (void *entry) const |
Query file size from handle. | |
void | GetFileTime (void *entry, csFileTime &ztime) const |
Query filetime from handle. | |
void | SetFileTime (void *entry, const csFileTime &ztime) |
Set filetime for handle. | |
char * | GetName () const |
Query archive filename. | |
char * | GetComment () const |
Query archive comment. |
Detailed Description
This class can be used to work with standard ZIP archives.Constructor accepts a file name - if such a file is not found, it is created. After this you can examine archive directory, read files, delete or write files in archive.
Operations which changes archive file will be deferred until Flush() method is called. Before calling Flush() you can do any number of deletions and writes, but read operations will not be affected by these until Flush() will be called.
Known quirks:
- No CRC check is done on reading, although ZIP file format allows it. This design 'flaw' was allowed to achieve maximal speed. However, when a file is added to archive, its CRC is computed and updated correctly.
- Several methods of the csArchive class requires approximatively 20K of stack space when invoked.
- Doesn't like files >4GB.
Definition at line 56 of file archive.h.
Constructor & Destructor Documentation
|
Open the archive.
|
|
Close the archive.
|
Member Function Documentation
|
Delete a file from the archive. You won't see any changes to archive until 'Flush' will be called. |
|
Type a directory listing of the archive to the console.
|
|
Return true if a path exists. Also return the size of the file if needed. |
|
Find a file in archive; returns a handle or 0.
|
|
Execute all pending operations involving writes to archive Neither DeleteFile or NewFile will have effect until this function will be called. Returns false if operation failed. If operation failed, postponed operations remains in the same state as before calling Flush(), i.e. for example user can be prompted to free some space on drive then retry Flush(). |
|
Query archive comment.
|
|
Get Nth file in archive or 0.
|
|
Query name from handle.
|
|
Query file size from handle.
|
|
Query filetime from handle.
|
|
Query archive filename.
|
|
Create a new file in the archive. If the file already exists it will be overwritten. Returns 0 if not succesful. Otherwise it returns a pointer that can be passed to 'Write' routine. You won't see any changes to archive until 'Flush' will be called. 'size' is the _advisory_ file size. There is no problem if you will write more or less bytes, its just a matter of performance - if you set the right size, archive manager will have to allocate memory only once; however if you set size to zero and then write all the data in one call, it will have same performance. |
|
Read a file completely. After finishing with the returned data you need to 'delete[]' it. If the file does not exists this function returns 0. If "size" is not null, it is set to unpacked size of the file. |
|
Set filetime for handle.
|
|
Write data to a file. Note that 'size' need not be the overall file size if this was given in 'NewFile', but this function will fail if the total size of written data exceeds the maximum size given to 'NewFile'. |
The documentation for this class was generated from the following file:
- csutil/archive.h
Generated for Crystal Space by doxygen 1.3.9.1