Loading...
Searching...
No Matches
SdfZipFileWriter Class Reference

Class for writing a zip file. More...

#include <zipFile.h>

Public Member Functions

SDF_API SdfZipFileWriter ()
 Create an invalid SdfZipFileWriter object.
 
SDF_API ~SdfZipFileWriter ()
 Calls Save()
 
 SdfZipFileWriter (const SdfZipFileWriter &)=delete
 
SdfZipFileWriteroperator= (const SdfZipFileWriter &)=delete
 
SDF_API SdfZipFileWriter (SdfZipFileWriter &&rhs)
 
SDF_API SdfZipFileWriteroperator= (SdfZipFileWriter &&rhs)
 
SDF_API operator bool () const
 Returns true if this is a valid object, false otherwise.
 
SDF_API std::string AddFile (const std::string &filePath, const std::string &filePathInArchive=std::string())
 Adds the file at filePath to the zip archive with no compression applied.
 
SDF_API bool Save ()
 Finalizes the zip archive and saves it to the destination file path.
 
SDF_API void Discard ()
 Discards the zip archive so that it is not saved to the destination file path.
 

Static Public Member Functions

static SDF_API SdfZipFileWriter CreateNew (const std::string &filePath)
 Create a new file writer with filePath as the destination file path where the zip archive will be written.
 

Detailed Description

Class for writing a zip file.

This class is primarily intended to support the .usdz file format. It is not a general-purpose zip writer, as it does not implement the full zip file specification. However, all files written by this class should be valid zip files and readable by external zip libraries and utilities.

Definition at line 215 of file zipFile.h.

Constructor & Destructor Documentation

◆ SdfZipFileWriter()

SDF_API SdfZipFileWriter ( )

Create an invalid SdfZipFileWriter object.

◆ ~SdfZipFileWriter()

SDF_API ~SdfZipFileWriter ( )

Calls Save()

Member Function Documentation

◆ AddFile()

SDF_API std::string AddFile ( const std::string &  filePath,
const std::string &  filePathInArchive = std::string() 
)

Adds the file at filePath to the zip archive with no compression applied.

If filePathInArchive is non-empty, the file will be added at that path in the archive. Otherwise, it will be added at filePath.

Returns the file path used to identify the file in the zip archive on success. This path conforms to the zip file specification and may not be the same as filePath or filePathInArchive. Returns an empty string on failure.

◆ CreateNew()

static SDF_API SdfZipFileWriter CreateNew ( const std::string &  filePath)
static

Create a new file writer with filePath as the destination file path where the zip archive will be written.

The zip file will not be written to filePath until the writer is destroyed or Save() is called.

Returns an invalid object on error.

◆ Discard()

SDF_API void Discard ( )

Discards the zip archive so that it is not saved to the destination file path.

Once discarded, the file writer is invalid and may not be reused.

◆ operator bool()

SDF_API operator bool ( ) const
inlineexplicit

Returns true if this is a valid object, false otherwise.

Definition at line 244 of file zipFile.h.

◆ Save()

SDF_API bool Save ( )

Finalizes the zip archive and saves it to the destination file path.

Once saved, the file writer is invalid and may not be reused. Returns true on success, false otherwise.


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