Open 3D Engine Archive Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Archive::ArchiveReader Class Reference

#include <ArchiveReader.h>

Inherits Archive::IArchiveReader.

Public Member Functions

 AZ_TYPE_INFO_WITH_NAME_DECL (ArchiveReader)
 
 AZ_RTTI_NO_TYPE_INFO_DECL ()
 
 ArchiveReader (const ArchiveReaderSettings &readerSettings)
 Create an archive reader using the specified reader settings.
 
 ArchiveReader (AZ::IO::PathView archivePath, const ArchiveReaderSettings &readerSettings={})
 
 ArchiveReader (ArchiveStreamPtr archiveStream, const ArchiveReaderSettings &readerSettings={})
 Takes ownership of the open stream and will optionally delete it based on the ArchiveFileDeleter.
 
bool MountArchive (AZ::IO::PathView archivePath) override
 
bool MountArchive (ArchiveStreamPtr archiveStream) override
 
void UnmountArchive () override
 Closes the handle to the mounted archive stream.
 
bool IsMounted () const override
 Returns if an open archive that is mounted.
 
ArchiveExtractFileResult ExtractFileFromArchive (AZStd::span< AZStd::byte > outputSpan, const ArchiveReaderFileSettings &fileSettings) override
 
ArchiveListFileResult ListFileInArchive (ArchiveFileToken filePathToken) const override
 
ArchiveListFileResult ListFileInArchive (AZ::IO::PathView relativePath) const override
 
bool ContainsFile (AZ::IO::PathView relativePath) const override
 
EnumerateArchiveResult EnumerateFilesInArchive (ListFileCallback listFileCallback) const override
 
bool DumpArchiveMetadata (AZ::IO::GenericStream &metadataStream, const ArchiveMetadataSettings &metadataSettings={}) const override
 
- Public Member Functions inherited from Archive::IArchiveReader
 AZ_TYPE_INFO_WITH_NAME_DECL (IArchiveReader)
 
 AZ_RTTI_NO_TYPE_INFO_DECL ()
 
virtual bool MountArchive (AZ::IO::PathView archivePath)=0
 
virtual bool MountArchive (ArchiveStreamPtr archiveStream)=0
 
virtual void UnmountArchive ()=0
 Closes the handle to the mounted archive stream.
 
virtual bool IsMounted () const =0
 Returns if an open archive that is mounted.
 
virtual ArchiveExtractFileResult ExtractFileFromArchive (AZStd::span< AZStd::byte > outputSpan, const ArchiveReaderFileSettings &fileSettings)=0
 
virtual ArchiveListFileResult ListFileInArchive (ArchiveFileToken filePathToken) const =0
 
virtual ArchiveListFileResult ListFileInArchive (AZ::IO::PathView relativePath) const =0
 
virtual bool ContainsFile (AZ::IO::PathView relativePath) const =0
 
virtual EnumerateArchiveResult EnumerateFilesInArchive (ListFileCallback listFileCallback) const =0
 
virtual bool DumpArchiveMetadata (AZ::IO::GenericStream &metadataStream, const ArchiveMetadataSettings &metadataSettings={}) const =0
 

Public Attributes

 AZ_CLASS_ALLOCATOR_DECL
 
- Public Attributes inherited from Archive::IArchiveReader
 AZ_CLASS_ALLOCATOR_DECL
 

Additional Inherited Members

- Public Types inherited from Archive::IArchiveReader
using ArchiveStreamPtr = AZStd::unique_ptr< AZ::IO::GenericStream, ArchiveStreamDeleter >
 
using ListFileCallback = AZStd::function< bool(ArchiveListFileResult)>
 

Detailed Description

Implements the Archive Reader Interface This can be used to read and extract files from an archive

Constructor & Destructor Documentation

◆ ArchiveReader()

Archive::ArchiveReader::ArchiveReader ( AZ::IO::PathView  archivePath,
const ArchiveReaderSettings readerSettings = {} 
)
explicit

Open an file at the specified file path and takes sole ownership of it The ArchiveReader will close the file on Unmount

Member Function Documentation

◆ ContainsFile()

bool Archive::ArchiveReader::ContainsFile ( AZ::IO::PathView  relativePath) const
overridevirtual

Returns if the archive contains a relative path

Parameters
relativePathRelative path within archive to search for
Returns
true if the relative path is contained with the Archive equivalent to return FindFile(relativePath) != InvalidArchiveFileToken;

Implements Archive::IArchiveReader.

◆ DumpArchiveMetadata()

bool Archive::ArchiveReader::DumpArchiveMetadata ( AZ::IO::GenericStream &  metadataStream,
const ArchiveMetadataSettings metadataSettings = {} 
) const
overridevirtual

Dump metadata for the archive to the supplied generic stream

Parameters
metadataStreamarchive file metadata will be written to the stream
metadataSettingssettings using which control the file metadata to write to the stream
Returns
true if metadata was successfully written

Implements Archive::IArchiveReader.

◆ EnumerateFilesInArchive()

EnumerateArchiveResult Archive::ArchiveReader::EnumerateFilesInArchive ( ListFileCallback  listFileCallback) const
overridevirtual

Enumerates all files within the archive table of contents and invokes a callback function with the listing information about the file This function can be used to build filter files in the Archive based on any value supplied in the ArchiveListFileResult structure For example filtering can be done based on file path(such as globbing for all *.txt files) or filtering based on uncompressed size(such as locating all files > 2MiB, etc...) Alternatively this function can be used to list all of the files within the archive by binding a lambda that populates a vector

Parameters
listFileCallbackCallback which is invoked for each file in the archive
Returns
result structure that is convertible to a boolean value indicating if enumeration was successful

Implements Archive::IArchiveReader.

◆ ExtractFileFromArchive()

ArchiveExtractFileResult Archive::ArchiveReader::ExtractFileFromArchive ( AZStd::span< AZStd::byte >  outputSpan,
const ArchiveReaderFileSettings fileSettings 
)
overridevirtual

Reads the content of the file specified in the ArchiveReadeFileSettings The file path identifier in the settings is used to locate the file to extract from the archive The outputSpan should be a pre-allocated buffer that is large enough to fit either the uncompressed size of the file if the m_decompressFile setting is true or the compressed size of the file if the m_decompressFile setting is false

Parameters
outputSpanpre-allocated buffer that should be large enough to store the extracted file
fileSettingssettings which can configure whether the file should be decompressed, the start offset where to start reading content within the file, how many bytes to read from the file, etc...
Returns
ArchiveExtractFileResult structure which on success contains a span of the actual data extracted from the Archive. NOTE: The extracted data can be smaller than the outputSpan.size() On failure, the result outcome member contains the error that occurred

Implements Archive::IArchiveReader.

◆ IsMounted()

bool Archive::ArchiveReader::IsMounted ( ) const
overridevirtual

Returns if an open archive that is mounted.

Implements Archive::IArchiveReader.

◆ ListFileInArchive() [1/2]

ArchiveListFileResult Archive::ArchiveReader::ListFileInArchive ( ArchiveFileToken  filePathToken) const
overridevirtual

List the file metadata from the archive using the ArchiveFileToken

Parameters
filePathTokenidentifier token that can be used to quickly lookup metadata about the file
Returns
ArchiveListResult with metadata for the file if found

Implements Archive::IArchiveReader.

◆ ListFileInArchive() [2/2]

ArchiveListFileResult Archive::ArchiveReader::ListFileInArchive ( AZ::IO::PathView  relativePath) const
overridevirtual

List the file metadata from the archive using the relative FilePath

Parameters
relativePathFile path to lookup within the archive
Returns
ArchiveListResult with metadata for the file if found

Implements Archive::IArchiveReader.

◆ MountArchive() [1/2]

bool Archive::ArchiveReader::MountArchive ( ArchiveStreamPtr  archiveStream)
overridevirtual

◆ MountArchive() [2/2]

bool Archive::ArchiveReader::MountArchive ( AZ::IO::PathView  archivePath)
overridevirtual

Opens the archive path and returns true if successful Will unmount any previously mounted archive

Implements Archive::IArchiveReader.

◆ UnmountArchive()

void Archive::ArchiveReader::UnmountArchive ( )
overridevirtual

Closes the handle to the mounted archive stream.

Implements Archive::IArchiveReader.


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