#include <ArchiveWriter.h>
Inherits Archive::IArchiveWriter.
|
| AZ_CLASS_ALLOCATOR_DECL |
|
| AZ_CLASS_ALLOCATOR_DECL |
|
class which is used to write into a stream the O3DE Archive format The caller is required to supply a ArchiveWriterSettings structure which contains the ArchiveHeader and ArchiveTableOfContents data to use when writing to the Archive file The class can be initialized with a user supplied AZ::IO::GenericStream class in which case it should be open in stream should needs to be open with OpenMode::ModeUpdate The reason why is that to locate information about any content files in order to update an existing archive it read access is needed The recommend OpenMode value for opening a new archive or updating an existing archive are as follows constexpr OpenMode mode = OpenMode::Update | OpenMode::Append | OpenMode::Binary The Append option makes sure that the Archive is not truncated on open
◆ CommitResult
Write the updated ArchiveHeader to the beginning of the stream and Table of Contents to end of the stream
If this call is successful, the archive TOC has been successfully written This function has been marked [[nodiscard]], to ensure the caller checks the return value
- Returns
- A successful expectation if the TOC has been written
◆ ArchiveWriter()
Archive::ArchiveWriter::ArchiveWriter |
( |
AZ::IO::PathView |
archivePath, |
|
|
const ArchiveWriterSettings & |
writerSettings = {} |
|
) |
| |
|
explicit |
Open an file at the specified file path and takes sole ownership of it The ArchiveWriter will close the file on Unmount
◆ AddFileToArchive() [1/2]
Adds the content from the stream to the relative path
- Parameters
-
inputStream | stream class where data for the file is source from The entire stream is read into the memory and written into archive |
fileSettings | settings used to configure the relative path to write to the archive for the given file data. It also allows users to configure the compression algorithm to use, and whether the AddFileToArchive logic fails if an existing file is being added |
- Returns
- ArchiveAddFileResult containing the actual compression file path as saved to the Archive TOC, the compression algorithm used and an Archive File Token which can be used to remove the file if need be On failure, the result outcome contains any errors that have occurred
Implements Archive::IArchiveWriter.
◆ AddFileToArchive() [2/2]
Use the span contents to add the file to the archive
- Parameters
-
inputSpan | view of data which will be written to the archive at the relative path supplied in the @fileSettings parameter |
fileSettings | settings used to configure the relative path to write to the archive for the given file data. It also allows users to configure the compression algorithm to use, and whether the AddFileToArchive logic fails if an existing file is being added |
- Returns
- ArchiveAddFileResult containing the actual compression file path as saved to the Archive TOC, the compression algorithm used and an Archive File Token which can be used to remove the file if need be On failure, the result outcome contains any errors that have occurred
Implements Archive::IArchiveWriter.
◆ ContainsFile()
bool Archive::ArchiveWriter::ContainsFile |
( |
AZ::IO::PathView |
relativePath | ) |
const |
|
overridevirtual |
Returns if the archive contains a relative path
- Parameters
-
relativePath | Relative 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::IArchiveWriter.
◆ DumpArchiveMetadata()
bool Archive::ArchiveWriter::DumpArchiveMetadata |
( |
AZ::IO::GenericStream & |
metadataStream, |
|
|
const ArchiveMetadataSettings & |
metadataSettings = {} |
|
) |
| const |
|
overridevirtual |
Dump metadata for the archive to the supplied generic stream
- Parameters
-
metadataStream | archive file metadata will be written to the stream |
metadataSettings | settings using which control the file metadata to write to the stream |
- Returns
- true if metadata was successfully written
Implements Archive::IArchiveWriter.
◆ FindFile()
ArchiveFileToken Archive::ArchiveWriter::FindFile |
( |
AZ::IO::PathView |
relativePath | ) |
const |
|
overridevirtual |
Searches for a relative path within the archive
- Parameters
-
relativePath | Relative path within archive to search for |
- Returns
- A token that identifies the Archive file if it exist if the with the specified path doesn't exist InvalidArchiveFileToken is returned
Implements Archive::IArchiveWriter.
◆ MountArchive()
bool Archive::ArchiveWriter::MountArchive |
( |
AZ::IO::PathView |
archivePath | ) |
|
|
overridevirtual |
Opens the archive path and returns true if successful Will unmount any previously mounted archive
Implements Archive::IArchiveWriter.
◆ RemoveFileFromArchive() [1/2]
Removes the file from the archive using the ArchiveFileToken
- Parameters
-
filePathToken | Identifier queried using FindFile or AddFileToArchive NOTE: The entry in the table of contents is not actually removed The index where the file is located using the filePathToken is just added to the removed file indices set |
- Returns
- ArchiveRemoveResult with metadata about how the deleted file was stored in the Archive
Implements Archive::IArchiveWriter.
◆ RemoveFileFromArchive() [2/2]
Removes the file from the archive using a relative path name
- Parameters
-
relativePath | relative path within archive to search for |
- Returns
- ArchiveRemoveResult with metadata about how the deleted file was stored in the Archive
Implements Archive::IArchiveWriter.
◆ UnmountArchive()
void Archive::ArchiveWriter::UnmountArchive |
( |
| ) |
|
|
overridevirtual |
Closes the handle to the mounted archive stream This will invoke the Commit() function to write the archive TOC to the stream before closing the stream
Implements Archive::IArchiveWriter.
The documentation for this class was generated from the following file:
- Gems/Archive/Code/Source/Tools/ArchiveWriter.h