Loading...
Searching...
No Matches
UsdZipFile 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

USD_API UsdZipFile ()
 Create an invalid UsdZipFile object.
 
USD_API operator bool () const
 Return true if this object is valid, false otherwise.
 
USD_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.
 
USD_API Iterator end () const
 Returns end iterator for this zip archive.
 
Iterator cend () const
 Returns end iterator for this zip archive.
 
USD_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.
 
USD_API void DumpContents () const
 Print out listing of contents of this zip archive to stdout.
 

Static Public Member Functions

static USD_API UsdZipFile Open (const std::string &filePath)
 Opens the zip archive at filePath.
 
static USD_API UsdZipFile 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 56 of file zipFile.h.


Class Documentation

◆ UsdZipFile::FileInfo

class UsdZipFile::FileInfo

Information for a file in the zip archive.

Definition at line 85 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

◆ UsdZipFile()

USD_API UsdZipFile ( )

Create an invalid UsdZipFile object.

Member Function Documentation

◆ begin()

USD_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 198 of file zipFile.h.

◆ cend()

Iterator cend ( ) const
inline

Returns end iterator for this zip archive.

Definition at line 205 of file zipFile.h.

◆ DumpContents()

USD_API void DumpContents ( ) const

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

For diagnostic purposes only.

◆ end()

USD_API Iterator end ( ) const

Returns end iterator for this zip archive.

◆ Find()

USD_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 USD_API UsdZipFile Open ( const std::shared_ptr< ArAsset > &  asset)
static

Opens the zip archive asset.

Returns invalid object on error.

◆ Open() [2/2]

static USD_API UsdZipFile Open ( const std::string &  filePath)
static

Opens the zip archive at filePath.

Returns invalid object on error.

◆ operator bool()

USD_API operator bool ( ) const
inlineexplicit

Return true if this object is valid, false otherwise.

Definition at line 81 of file zipFile.h.


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