Loading...
Searching...
No Matches
SdfZipFile Class Reference

Class for reading a zip file. More...

#include <zipFile.h>

Classes

class  FileInfo
 Information for a file in the zip archive. More...
 
class  Iterator
 Iterator for traversing and inspecting the contents of the zip archive. More...
 

Public Member Functions

SDF_API SdfZipFile ()
 Create an invalid SdfZipFile object.
 
SDF_API operator bool () const
 Return true if this object is valid, false otherwise.
 
SDF_API Iterator begin () const
 Returns iterator pointing to the first file in the zip archive.
 
Iterator cbegin () const
 Returns iterator pointing to the first file in the zip archive.
 
SDF_API Iterator end () const
 Returns end iterator for this zip archive.
 
Iterator cend () const
 Returns end iterator for this zip archive.
 
SDF_API Iterator Find (const std::string &path) const
 Returns iterator to the file with the given path in this zip archive, or end() if no such file exists.
 
SDF_API void DumpContents () const
 Print out listing of contents of this zip archive to stdout.
 

Static Public Member Functions

static SDF_API SdfZipFile Open (const std::string &filePath)
 Opens the zip archive at filePath.
 
static SDF_API SdfZipFile Open (const std::shared_ptr< ArAsset > &asset)
 Opens the zip archive asset.
 

Detailed Description

Class for reading a zip file.

This class is primarily intended to support the .usdz file format. It is not a general-purpose zip reader, as it does not implement the full zip file specification. In particular:

  • This class does not natively support decompressing data from a zip archive. Clients may access the data exactly as stored in the file and perform their own decompression if desired.
  • This class does not rely on the central directory in order to read the contents of the file. This allows it to operate on partial zip archives. However, this also means it may handle certain zip files incorrectly. For example, if a file was deleted from a zip archive by just removing its central directory header, that file will still be found by this class.

Definition at line 40 of file zipFile.h.


Class Documentation

◆ SdfZipFile::FileInfo

class SdfZipFile::FileInfo

Information for a file in the zip archive.

Definition at line 69 of file zipFile.h.

Class Members
uint16_t compressionMethod = 0 Compression method for this file.

See section 4.4.5 of the zip file specification for valid values. In particular, a value of 0 means this file is stored with no compression.

size_t crc = 0 CRC-32 value of the uncompressed file.
size_t dataOffset = 0 Offset of the beginning of this file's data from the start of the zip archive.
bool encrypted = false Whether or not this file is encrypted.
size_t size = 0 Size of this file as stored in the zip archive.

If this file is compressed, this is its compressed size. Otherwise, this is the same as the uncompressed size.

size_t uncompressedSize = 0 Uncompressed size of this file.

This may not be the same as the size of the file as stored in the zip archive.

Constructor & Destructor Documentation

◆ SdfZipFile()

SDF_API SdfZipFile ( )

Create an invalid SdfZipFile object.

Member Function Documentation

◆ begin()

SDF_API Iterator begin ( ) const

Returns iterator pointing to the first file in the zip archive.

◆ cbegin()

Iterator cbegin ( ) const
inline

Returns iterator pointing to the first file in the zip archive.

Definition at line 182 of file zipFile.h.

◆ cend()

Iterator cend ( ) const
inline

Returns end iterator for this zip archive.

Definition at line 189 of file zipFile.h.

◆ DumpContents()

SDF_API void DumpContents ( ) const

Print out listing of contents of this zip archive to stdout.

For diagnostic purposes only.

◆ end()

SDF_API Iterator end ( ) const

Returns end iterator for this zip archive.

◆ Find()

SDF_API Iterator Find ( const std::string &  path) const

Returns iterator to the file with the given path in this zip archive, or end() if no such file exists.

◆ Open() [1/2]

static SDF_API SdfZipFile Open ( const std::shared_ptr< ArAsset > &  asset)
static

Opens the zip archive asset.

Returns invalid object on error.

◆ Open() [2/2]

static SDF_API SdfZipFile Open ( const std::string &  filePath)
static

Opens the zip archive at filePath.

Returns invalid object on error.

◆ operator bool()

SDF_API operator bool ( ) const
inlineexplicit

Return true if this object is valid, false otherwise.

Definition at line 65 of file zipFile.h.


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