#include <archive.h>
Public Methods | |
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. More... | |
bool | DeleteFile (const char *name) |
Delete a file from the archive. More... | |
bool | FileExists (const char *name, size_t *size=NULL) const |
Return true if a file exists. More... | |
char* | Read (const char *name, size_t *size=NULL) |
Read a file completely. More... | |
bool | Write (void *entry, const char *data, size_t size) |
Write data to a file. More... | |
bool | Flush () |
Execute all pending operations involving writes to archive Neither DeleteFile or NewFile will have effect until this function will be called. More... | |
void* | GetFile (int no) |
Get Nth file in archive or NULL. | |
void* | FindName (const char *name) const |
Find a file in archive; returns a handle or NULL. | |
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. | |
Static Public Attributes | |
char | hdr_central [4] |
char | hdr_local [4] |
char | hdr_endcentral [4] |
char | hdr_extlocal [4] |
Friends | |
class | ArchiveEntry |
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:
|
Delete a file from the archive. You won't see any changes to archive until 'Flush' will be called. |
|
Return true if a file exists. Also return the size of the file if needed. |
|
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(). |
|
Create a new file in the archive. If the file already exists it will be overwritten. Calling NewFile twice with same filename without calling Flush() inbetween will cause unpredictable results. Returns NULL 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 NULL. If "size" is not null, it is set to unpacked size of the file. |
|
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'. |