Using PathView to pass paths to APIs
This commit is contained in:
@@ -12,7 +12,7 @@ namespace fs
|
||||
|
||||
namespace
|
||||
{
|
||||
UnzipResult unzip(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::unique_ref<ZipPack> zipPack)
|
||||
UnzipResult unzip(IFilesystem& dstFilesystem, AbsPathView filePath, tl::unique_ref<ZipPack> zipPack)
|
||||
{
|
||||
MakeFolderResult makeFolderResult = dstFilesystem.makeFolder(filePath);
|
||||
if (makeFolderResult.has_error())
|
||||
@@ -21,7 +21,7 @@ UnzipResult unzip(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::uniqu
|
||||
for (const EnumerateEntry& ee: zipPack->enumerateRecursively(AbsPath("/")))
|
||||
{
|
||||
AbsPath dstPath = filePath + ee.path;
|
||||
OUTCOME_TRY(dstFilesystem.makeFolder(ee.isFolder ? dstPath : dstPath.parent()));
|
||||
OUTCOME_TRY(dstFilesystem.makeFolder(ee.isFolder ? AbsPathView(dstPath) : dstPath.parent()));
|
||||
if (!ee.isFolder)
|
||||
{
|
||||
OUTCOME_TRY(auto source, zipPack->openStreamSource(AbsPath("/") + ee.path));
|
||||
@@ -34,20 +34,20 @@ UnzipResult unzip(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::uniqu
|
||||
}
|
||||
}
|
||||
|
||||
UnzipResult unzipSource(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::unique_ref<IMapSource> source)
|
||||
UnzipResult unzipSource(IFilesystem& dstFilesystem, AbsPathView filePath, tl::unique_ref<IMapSource> source)
|
||||
{
|
||||
OUTCOME_TRY(auto pack, ZipPack::create(std::move(source)));
|
||||
return unzip(dstFilesystem, filePath, std::move(pack));
|
||||
}
|
||||
|
||||
|
||||
UnzipResult unzipFile(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::lent_ref<const IFilesystem> filesystem, AbsPath srcFilePath)
|
||||
UnzipResult unzipFile(IFilesystem& dstFilesystem, AbsPathView filePath, tl::lent_ref<const IFilesystem> filesystem, AbsPathView srcFilePath)
|
||||
{
|
||||
OUTCOME_TRY(auto pack, ZipPack::create(std::move(filesystem), std::move(srcFilePath)));
|
||||
return unzip(dstFilesystem, filePath, std::move(pack));
|
||||
}
|
||||
|
||||
ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, const AbsPath& path, uint8_t compressionLevel, size_t fileDataAlignment)
|
||||
ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel, size_t fileDataAlignment)
|
||||
{
|
||||
ZipWriter writer(sink, fileDataAlignment);
|
||||
|
||||
@@ -67,7 +67,7 @@ ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, const Abs
|
||||
{
|
||||
if (!ee.isFolder)
|
||||
{
|
||||
tl::result<void> addResult = writer.addFile(ee.path.get_as<PosixSystem>(), [&filesystem, &path, &ee, compressionLevel](IStreamSink& sink)
|
||||
tl::result<void> addResult = writer.addFile(ee.path.str<PosixSystem>(), [&filesystem, &path, &ee, compressionLevel](IStreamSink& sink)
|
||||
{
|
||||
return DeflateFileWriter(path + ee.path, filesystem, compressionLevel)(sink);
|
||||
});
|
||||
@@ -81,7 +81,7 @@ ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, const Abs
|
||||
return tl::success();
|
||||
}
|
||||
|
||||
ZipResult zipToFile(IFilesystem& dstFilesystem, const AbsPath& dstFilePath, tl::lent_ref<IFilesystem> filesystem, const AbsPath& path, uint8_t compressionLevel, size_t fileDataAlignment)
|
||||
ZipResult zipToFile(IFilesystem& dstFilesystem, AbsPathView dstFilePath, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel, size_t fileDataAlignment)
|
||||
{
|
||||
OUTCOME_TRY(const auto sink, dstFilesystem.openSink(dstFilePath, Mode::CreateOrOpenAndClear));
|
||||
return zipToSink(*sink, std::move(filesystem), path, compressionLevel, fileDataAlignment);
|
||||
|
||||
Reference in New Issue
Block a user