Added embedded libzip
Prefixed all libzip zip_ funcs to fs_zip_ to avoid clashes and link errors due to assimp Zip pack and zip writer work with libzip now
This commit was merged in pull request #2.
This commit is contained in:
+16
-13
@@ -47,17 +47,18 @@ UnzipResult unzipFile(IFilesystem& dstFilesystem, AbsPathView filePath, tl::lent
|
||||
return unzip(dstFilesystem, filePath, std::move(pack));
|
||||
}
|
||||
|
||||
ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel, size_t fileDataAlignment)
|
||||
ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel)
|
||||
{
|
||||
ZipWriter writer(sink, fileDataAlignment);
|
||||
ZipWriter writer(sink);
|
||||
|
||||
OUTCOME_TRY(const bool isFile, filesystem->isFile(path));
|
||||
if (isFile)
|
||||
{
|
||||
tl::result<void> addResult = writer.addFile(path.str(), [&filesystem, &path, compressionLevel](IStreamSink& sink)
|
||||
{
|
||||
return DeflateFileWriter(path, filesystem, compressionLevel)(sink);
|
||||
});
|
||||
const auto openResult = filesystem->openSource(path);
|
||||
if (openResult.has_error())
|
||||
return tl::make_error<Error>(ErrorCode::SystemError, "Cannot open file '{}' zip: {}", path, openResult.error());
|
||||
|
||||
const auto addResult = writer.addFile(path.str(), compressionLevel, *openResult.value());
|
||||
if (addResult.has_error())
|
||||
return tl::make_error<Error>(ErrorCode::SystemError, "Cannot add file '{}' zip: {}", path, addResult.error());
|
||||
}
|
||||
@@ -67,12 +68,14 @@ ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, AbsPathVi
|
||||
{
|
||||
if (!ee.isFolder)
|
||||
{
|
||||
tl::result<void> addResult = writer.addFile(ee.path.str<PosixSystem>(), [&filesystem, &path, &ee, compressionLevel](IStreamSink& sink)
|
||||
{
|
||||
return DeflateFileWriter(path + ee.path, filesystem, compressionLevel)(sink);
|
||||
});
|
||||
auto localPath = path + ee.path;
|
||||
const auto openResult = filesystem->openSource(localPath);
|
||||
if (openResult.has_error())
|
||||
return tl::make_error<Error>(ErrorCode::SystemError, "Cannot open file '{}' zip: {}", localPath, openResult.error());
|
||||
|
||||
const auto addResult = writer.addFile(localPath.str(), compressionLevel, *openResult.value());
|
||||
if (addResult.has_error())
|
||||
return {tl::make_error<Error>(ErrorCode::SystemError, "Cannot add file '{}' zip: {}", path + ee.path, addResult.error())};
|
||||
return tl::make_error<Error>(ErrorCode::SystemError, "Cannot add file '{}' zip: {}", localPath, addResult.error());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,10 +84,10 @@ ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, AbsPathVi
|
||||
return tl::success();
|
||||
}
|
||||
|
||||
ZipResult zipToFile(IFilesystem& dstFilesystem, AbsPathView dstFilePath, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel, size_t fileDataAlignment)
|
||||
ZipResult zipToFile(IFilesystem& dstFilesystem, AbsPathView dstFilePath, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel)
|
||||
{
|
||||
OUTCOME_TRY(const auto sink, dstFilesystem.openSink(dstFilePath, Mode::CreateOrOpenAndClear));
|
||||
return zipToSink(*sink, std::move(filesystem), path, compressionLevel, fileDataAlignment);
|
||||
return zipToSink(*sink, std::move(filesystem), path, compressionLevel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user