Nebula
Loading...
Searching...
No Matches
ziparchive.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
18#include "minizip/unzip.h"
21
22//------------------------------------------------------------------------------
23namespace IO
24{
25class ZipArchive : public ArchiveBase
26{
28public:
30 ZipArchive();
32 virtual ~ZipArchive();
33
35 bool Setup(const URI& uri, const Util::String& rootPath = "");
37 void Discard();
38
40 Util::Array<Util::String> ListFiles(const Util::String& dirPathInArchive, const Util::String& pattern) const;
42 Util::Array<Util::String> ListDirectories(const Util::String& dirPathInArchive, const Util::String& pattern) const;
44 URI ConvertToArchiveURI(const URI& fileURI) const;
47
48private:
49 friend class ZipFileSystem;
50 friend class ZipFileStream;
51
55 void AddEntry(const Util::String& path);
57 const ZipFileEntry* FindFileEntry(const Util::String& pathInZipArchive) const;
59 ZipFileEntry* FindFileEntry(const Util::String& pathInZipArchive);
61 const ZipDirEntry* FindDirEntry(const Util::String& pathInZipArchive) const;
62
63 Util::String rootPath; // location of the zip archive file
64 unzFile zipFileHandle; // the zip file handle
65 ZipDirEntry rootEntry; // the root entry of the zip archive
66 Threading::CriticalSection archiveCritSect; // need to serialize access to archive from multiple threads!
67 zlib_filefunc64_def zlibIoFuncs; // io functions struct from zlib to nebula
68};
69
70} // namespace IO
71//------------------------------------------------------------------------------
Base class of file archives.
Definition archivebase.h:20
URI uri
Definition archivebase.h:48
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition uri.h:67
Private helper class for ZipFileSystem to hold per-Zip-archive data.
Definition ziparchive.h:26
URI ConvertToArchiveURI(const URI &fileURI) const
convert a "file:" URI into a "zip:" URI pointing into this archive
Definition ziparchive.cc:347
virtual ~ZipArchive()
destructor
Definition ziparchive.cc:31
ZipArchive()
constructor
Definition ziparchive.cc:22
Util::String ConvertToPathInArchive(const Util::String &absPath) const
convert an absolute path to local path inside archive, returns empty string if absPath doesn't point ...
Definition ziparchive.cc:193
const ZipFileEntry * FindFileEntry(const Util::String &pathInZipArchive) const
find a file entry in the zip archive, return 0 if not exists
Definition ziparchive.cc:212
void ParseTableOfContents()
parse the table of contents into memory
Definition ziparchive.cc:104
ZipDirEntry rootEntry
Definition ziparchive.h:65
Util::String rootPath
Definition ziparchive.h:63
__DeclareClass(ZipArchive)
Threading::CriticalSection archiveCritSect
Definition ziparchive.h:66
Util::Array< Util::String > ListDirectories(const Util::String &dirPathInArchive, const Util::String &pattern) const
list all subdirectories in a directory in the archive
Definition ziparchive.cc:319
bool Setup(const URI &uri, const Util::String &rootPath="")
setup the archive from an URI
Definition ziparchive.cc:45
void Discard()
discard the archive
Definition ziparchive.cc:88
const ZipDirEntry * FindDirEntry(const Util::String &pathInZipArchive) const
find a directory entry in the zip archive, return 0 if not exists
Definition ziparchive.cc:261
Util::Array< Util::String > ListFiles(const Util::String &dirPathInArchive, const Util::String &pattern) const
list all files in a directory in the archive
Definition ziparchive.cc:294
zlib_filefunc64_def zlibIoFuncs
Definition ziparchive.h:67
unzFile zipFileHandle
Definition ziparchive.h:64
void AddEntry(const Util::String &path)
add a new file entry, create missing dir entries on the way
Definition ziparchive.cc:137
A directory entry in a zip arcive.
Definition zipdirentry.h:21
A file entry in a zip archive.
Definition zipfileentry.h:22
Wraps a file in a zip archive into a stream.
Definition zipfilestream.h:39
An archive filesystem wrapper for ZIP files.
Definition zipfilesystem.h:41
Critical section objects are used to protect a portion of code from parallel execution.
Nebula's dynamic array class.
Definition array.h:60
Instances of wrapped stream classes.
Definition orientation.cc:10
Nebula's universal string class.
Definition string.h:50