About
maxon::WriteArchiveInterface and maxon::ReadArchiveInterface are generic interfaces giving access to archive files. These interfaces are typically used to read and write ZIP files.
Writer
The maxon::WriteArchiveInterface allows to create archive files and to add virtual files to the archive.
Implementations of this interface are registered at the maxon::WriteArchiveClasses registry and are also accessible as published object:
- maxon::WriteArchiveClasses::Zip: Implementation to write ZIP archives.
const maxon::WriteArchiveRef zipArchive = maxon::WriteArchiveClasses::Zip().Create()
iferr_return;
zipArchive.CreateFile(
"text.txt"_s, time, method, attributes, 0)
iferr_return;
zipArchive.CreateFile(
"exampleFolder/text.txt"_s, time, method, attributes, 0)
iferr_return;
Reader
The maxon::ReadArchiveInterface allows to open and read archive files.
Implementations of this interface are registered at the maxon::ReadArchiveClasses registry and are also accessible as published object:
- maxon::ReadArchiveClasses::Zip: Implementation of read ZIP archives.
{
return true;
};
const maxon::ReadArchiveRef zipArchive = maxon::ReadArchiveClasses::Zip().Create()
iferr_return;
File Formats
These maxon::FileFormatHandler allow to browse an archive file or to easily read it:
- maxon::FileFormatHandlers::ZipDirectoryBrowser: Creates a maxon::IoBrowseRef to browse the virtual files of a ZIP file.
- maxon::FileFormatHandlers::GZipDirectoryBrowser: Creates a maxon::IoBrowseRef to browse the virtual files of a GZip file.
- maxon::FileFormatHandlers::ZipArchiveHandler: Creates a maxon::ReadArchiveRef to read file from a ZIP file.
const maxon::FileFormatHandler& zipDirBrowser = maxon::FileFormatHandlers::ZipDirectoryBrowser();
auto handler = zipDirBrowser.CreateHandler<maxon::IoBrowseRef>(zipFile);
for (auto it : handler)
{
const maxon::IoBrowseRef& browseIterator = (it)
iferr_return;
}
{
const maxon::Url currentFile = browseIterator.GetCurrentPath();
{
{
const maxon::IoBrowseRef& subIterator = (subIt)
iferr_return;
}
}
}
const maxon::FileFormatHandler& handler = maxon::FileFormatHandlers::ZipArchiveHandler();
const maxon::ReadArchiveRef zipArchive = handler.CreateHandler<maxon::ReadArchiveRef>(
maxon::Url())
iferr_return;
Further Reading