Using PathView to pass paths to APIs
This commit is contained in:
@@ -14,9 +14,9 @@ template<typename parse_separators, typename format_separator>
|
||||
struct WindowsSystemCustom : public tl::detail::path_system::base_path_system<parse_separators, format_separator>
|
||||
{
|
||||
template<typename T>
|
||||
static T format_absolute(const tl::vector<tl::string>& members);
|
||||
static void parse_absolute(tl::vector<tl::string>& o_elements, const char* path, size_t size);
|
||||
static bool validate_abs_path(const tl::vector<tl::string>& members);
|
||||
static T format_abs(tl::span<const tl::string> members);
|
||||
static void parse_abs(tl::vector<tl::string>& o_elements, const char* path, size_t size);
|
||||
static bool validate_abs_path(tl::span<const tl::string> members);
|
||||
static bool match(const char* path, size_t size);
|
||||
};
|
||||
TL_DECLARE_STRING_VECTOR(WindowsParseSeparators, "\\", "/");
|
||||
@@ -35,8 +35,10 @@ TL_DECLARE_STRING_VECTOR(UncParseSeparators, "\\", "/");
|
||||
TL_DECLARE_STRING_LITERAL(UncFormatSeparator, "\\");
|
||||
using UncSystem = tl::simple_path_system<UncRootTag, UncParseSeparators, UncFormatSeparator>;
|
||||
|
||||
using AbsPath = tl::abs_path<tl::path_systems<WindowsSystem, PosixSystem, UncSystem> >;
|
||||
using AbsPath = tl::abs_path<tl::path_systems<WindowsSystem, PosixSystem, UncSystem>>;
|
||||
using AbsPathView = AbsPath::path_view_type;
|
||||
using RelPath = AbsPath::rel_path_type;
|
||||
using RelPathView = RelPath::path_view_type;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +50,6 @@ struct std::formatter<fs::RelPath>
|
||||
constexpr auto parse(format_parse_context& ctx) noexcept { return ctx.begin(); }
|
||||
auto format(const fs::RelPath& p, std::format_context& ctx) const
|
||||
{
|
||||
return format_to(ctx.out(), "{}", p.get_as<fs::PosixSystem>());
|
||||
return format_to(ctx.out(), "{}", p.str<fs::PosixSystem>());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,16 +12,16 @@ namespace detail
|
||||
// windows path system
|
||||
template<typename parse_separators, typename format_separator>
|
||||
template<typename T>
|
||||
T WindowsSystemCustom<parse_separators, format_separator>::format_absolute(const tl::vector<tl::string>& members)
|
||||
T WindowsSystemCustom<parse_separators, format_separator>::format_abs(tl::span<const tl::string> members)
|
||||
{
|
||||
return tl::simple_path_system<detail::EmptyRootTag, parse_separators, format_separator>::template format_absolute<T>(members);
|
||||
return tl::simple_path_system<detail::EmptyRootTag, parse_separators, format_separator>::template format_abs<T>(members);
|
||||
}
|
||||
|
||||
template<typename parse_separators, typename format_separator>
|
||||
void WindowsSystemCustom<parse_separators, format_separator>::parse_absolute(tl::vector<tl::string>& o_elements, const char* path, size_t size)
|
||||
void WindowsSystemCustom<parse_separators, format_separator>::parse_abs(tl::vector<tl::string>& o_elements, const char* path, size_t size)
|
||||
{
|
||||
// On windows, the drive letter case is undefined. To avoid issues (hashing, etc), we always convert the drive letter to uppercase
|
||||
tl::simple_path_system<detail::EmptyRootTag, parse_separators, format_separator>::parse_absolute(o_elements, path, size);
|
||||
tl::simple_path_system<detail::EmptyRootTag, parse_separators, format_separator>::parse_abs(o_elements, path, size);
|
||||
if (!o_elements.empty())
|
||||
{
|
||||
tl::string& str = o_elements.front();
|
||||
@@ -42,7 +42,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template<typename parse_separators, typename format_separator>
|
||||
bool WindowsSystemCustom<parse_separators, format_separator>::validate_abs_path(const tl::vector<tl::string>& members)
|
||||
bool WindowsSystemCustom<parse_separators, format_separator>::validate_abs_path(tl::span<const tl::string> members)
|
||||
{
|
||||
return !members.empty() && match(members[0].c_str(), members[0].size());
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ FS_API uint64_t computeCRC64(uint64_t crc, tl::span<const uint8_t> data);
|
||||
|
||||
typedef tl::result<uint32_t, Error> CRC32StreamResult;
|
||||
FS_API CRC32StreamResult crc32Stream(IStreamSource& source, uint32_t crc = 0, size_t bufferSize = 0);
|
||||
FS_API CRC32StreamResult crc32File(const IFilesystem& filesystem, const AbsPath& filePath, uint32_t crc = 0, size_t bufferSize = 0);
|
||||
FS_API CRC32StreamResult crc32File(const IFilesystem& filesystem, AbsPathView filePath, uint32_t crc = 0, size_t bufferSize = 0);
|
||||
|
||||
typedef tl::result<uint64_t, Error> CRC64StreamResult;
|
||||
FS_API CRC64StreamResult crc64Stream(IStreamSource& source, uint64_t crc = 0, size_t bufferSize = 0);
|
||||
FS_API CRC64StreamResult crc64File(const IFilesystem& filesystem, const AbsPath& filePath, uint64_t crc = 0, size_t bufferSize = 0);
|
||||
FS_API CRC64StreamResult crc64File(const IFilesystem& filesystem, AbsPathView filePath, uint64_t crc = 0, size_t bufferSize = 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ class IFilesystem;
|
||||
using CopyStreamResult = tl::result<uint64_t, Error>;
|
||||
FS_API CopyStreamResult copyStream(IStreamSink& sink, IStreamSource& source, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyStream(IStreamSink& sink, IStreamSource& source, const ProcessDataCallback& dataCallback, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyFile(IStreamSink& sink, const IFilesystem& filesystem, const AbsPath& filePath, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyFile(IStreamSink& sink, const IFilesystem& filesystem, const AbsPath& filePath, const ProcessDataCallback& dataCallback, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyFile(IFilesystem& dstFilesystem, const AbsPath& dstFilePath, const IFilesystem& srcFilesystem, const AbsPath& srcFilePath, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyFile(IStreamSink& sink, const IFilesystem& filesystem, AbsPathView filePath, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyFile(IStreamSink& sink, const IFilesystem& filesystem, AbsPathView filePath, const ProcessDataCallback& dataCallback, size_t bufferSize = 0);
|
||||
FS_API CopyStreamResult copyFile(IFilesystem& dstFilesystem, AbsPathView dstFilePath, const IFilesystem& srcFilesystem, AbsPathView srcFilePath, size_t bufferSize = 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
|
||||
TL_DECLARE_INTEGRAL_ID(PackId, uint64_t)
|
||||
|
||||
tl::result<PackId> mountFront(AbsPath mountPoint, tl::unique_ref<IPack> pack);
|
||||
tl::result<PackId> mountBack(AbsPath mountPoint, tl::unique_ref<IPack> pack);
|
||||
tl::result<PackId> mountFront(AbsPathView mountPoint, tl::unique_ref<IPack> pack);
|
||||
tl::result<PackId> mountBack(AbsPathView mountPoint, tl::unique_ref<IPack> pack);
|
||||
|
||||
//unmounts all the packs for this point. It basically deletes the mount point
|
||||
cppcoro::generator<tl::unique_ref<IPack>> unmountAll();
|
||||
@@ -35,37 +35,37 @@ public:
|
||||
tl::unique_ptr<IPack> unmount(PackId packId);
|
||||
|
||||
//Returns the physical location of the virtual pack.
|
||||
ConvertToNativePathResult convertToNativePath(const AbsPath& path) const override;
|
||||
ConvertToNativePathResult convertToNativePath(AbsPathView path) const override;
|
||||
|
||||
OpenSourceResult openSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(const AbsPath& path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
OpenSinkResult openSink(const AbsPath& path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenStreamSinkResult openStreamSink(const AbsPath& path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenMapSinkResult openMapSink(const AbsPath& path, Mode mode, size_t size, SinkFlags flags = SinkFlags()) override;
|
||||
OpenSourceResult openSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(AbsPathView path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
OpenSinkResult openSink(AbsPathView path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenStreamSinkResult openStreamSink(AbsPathView path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenMapSinkResult openMapSink(AbsPathView path, Mode mode, size_t size, SinkFlags flags = SinkFlags()) override;
|
||||
|
||||
IsFileResult isFile(const AbsPath& path) const override;
|
||||
IsFolderResult isFolder(const AbsPath& path) const override;
|
||||
ExistsResult exists(const AbsPath& path) const override;
|
||||
IsFileResult isFile(AbsPathView path) const override;
|
||||
IsFolderResult isFolder(AbsPathView path) const override;
|
||||
ExistsResult exists(AbsPathView path) const override;
|
||||
|
||||
MakeFolderResult makeFolder(const AbsPath& path) override;
|
||||
MakeFolderResult makeFolder(AbsPathView path) override;
|
||||
|
||||
RenameResult rename(const AbsPath& path, const AbsPath& newPath) override;
|
||||
RenameResult rename(AbsPathView path, AbsPathView newPath) override;
|
||||
|
||||
RemoveResult remove(const AbsPath& path) override;
|
||||
RemoveRecursivelyResult removeRecursively(const AbsPath& path) override;
|
||||
RemoveResult remove(AbsPathView path) override;
|
||||
RemoveRecursivelyResult removeRecursively(AbsPathView path) override;
|
||||
|
||||
CopyResult copy(const AbsPath& path, const AbsPath& newPath) override;
|
||||
CopyResult copy(AbsPathView path, AbsPathView newPath) override;
|
||||
|
||||
MakeHardLinkResult makeHardLink(const AbsPath& sourcePath, const AbsPath& linkPath) override;
|
||||
MakeSoftLinkResult makeSymLink(const AbsPath& sourcePath, const AbsPath& linkPath) override;
|
||||
MakeHardLinkResult makeHardLink(AbsPathView sourcePath, AbsPathView linkPath) override;
|
||||
MakeSoftLinkResult makeSymLink(AbsPathView sourcePath, AbsPathView linkPath) override;
|
||||
|
||||
SetWriteTimeResult setWriteTime(const AbsPath& path, time_t time) override;
|
||||
SetWriteTimeResult setWriteTime(AbsPathView path, time_t time) override;
|
||||
|
||||
GetStatResult getStat(const AbsPath& path) const override;
|
||||
GetStatResult getStat(AbsPathView path) const override;
|
||||
|
||||
cppcoro::generator<EnumerateEntry> enumerate(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerate(AbsPathView path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPathView path) const override;
|
||||
|
||||
private:
|
||||
struct PackData
|
||||
@@ -86,14 +86,14 @@ private:
|
||||
};
|
||||
tl::vector<PackData> m_packsData;
|
||||
|
||||
void convertToPackPath(AbsPath& packPath, const AbsPath& path, const AbsPath& mountPoint) const;
|
||||
void convertToPackPath(AbsPath& packPath, AbsPathView path, AbsPathView mountPoint) const;
|
||||
|
||||
enum class MountPolicy
|
||||
{
|
||||
Front, //the pack will be mounted over packs from the same mount point. This pack will take precedence
|
||||
Back //the pack will be at the bottom of existing packs from the same mount point. Its streams will be searched last
|
||||
};
|
||||
tl::result<PackId> mount(AbsPath mountPoint, tl::unique_ref<IPack> pack, MountPolicy policy);
|
||||
tl::result<PackId> mount(AbsPathView mountPoint, tl::unique_ref<IPack> pack, MountPolicy policy);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class FS_API FileMapSink final : public IMapSink
|
||||
{
|
||||
friend class NativeFilesystem;
|
||||
public:
|
||||
FileMapSink(const AbsPath& filepath, size_t size, Mode mode = Mode::CreateOrOpenAndClear, Flags flags = Flags());
|
||||
FileMapSink(AbsPathView filepath, size_t size, Mode mode = Mode::CreateOrOpenAndClear, Flags flags = Flags());
|
||||
~FileMapSink() override;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
@@ -15,8 +15,8 @@ class FS_API FileMapSource final : public IMapSource
|
||||
{
|
||||
friend class NativeFilesystem;
|
||||
public:
|
||||
explicit FileMapSource(const AbsPath& filepath);
|
||||
FileMapSource(const AbsPath& filepath, uint64_t start, size_t size);
|
||||
explicit FileMapSource(AbsPathView filepath);
|
||||
FileMapSource(AbsPathView filepath, uint64_t start, size_t size);
|
||||
|
||||
~FileMapSource() override;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace fs
|
||||
class FS_API FileSink final : public ISink
|
||||
{
|
||||
public:
|
||||
FileSink(const AbsPath& filepath, Mode mode, Flags flags = Flags()) noexcept;
|
||||
FileSink(AbsPathView filepath, Mode mode, Flags flags = Flags()) noexcept;
|
||||
~FileSink() noexcept override;
|
||||
|
||||
FileSink(FileSink&& other) noexcept;
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace fs
|
||||
class FS_API FileSource final : public ISource
|
||||
{
|
||||
public:
|
||||
explicit FileSource(const AbsPath& i_filepath) noexcept;
|
||||
FileSource(const AbsPath& i_filepath, Flags i_flags) noexcept;
|
||||
explicit FileSource(AbsPathView i_filepath) noexcept;
|
||||
FileSource(AbsPathView i_filepath, Flags i_flags) noexcept;
|
||||
~FileSource() noexcept override;
|
||||
|
||||
FileSource(FileSource&& i_other) noexcept;
|
||||
|
||||
+13
-13
@@ -10,28 +10,28 @@ namespace fs
|
||||
class FS_API FolderPack : virtual public IPack
|
||||
{
|
||||
public:
|
||||
explicit FolderPack(AbsPath location);
|
||||
FolderPack(tl::lent_ref<IFilesystem> filesystem, AbsPath location);
|
||||
explicit FolderPack(AbsPathView location);
|
||||
FolderPack(tl::lent_ref<IFilesystem> filesystem, AbsPathView location);
|
||||
|
||||
~FolderPack() override = default;
|
||||
|
||||
OpenSourceResult openSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(const AbsPath& path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
OpenSourceResult openSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(AbsPathView path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
|
||||
IsFileResult isFile(const AbsPath& path) const override;
|
||||
IsFolderResult isFolder(const AbsPath& path) const override;
|
||||
ExistsResult exists(const AbsPath& path) const override;
|
||||
IsFileResult isFile(AbsPathView path) const override;
|
||||
IsFolderResult isFolder(AbsPathView path) const override;
|
||||
ExistsResult exists(AbsPathView path) const override;
|
||||
|
||||
GetStatResult getStat(const AbsPath& path) const override;
|
||||
GetStatResult getStat(AbsPathView path) const override;
|
||||
|
||||
cppcoro::generator<EnumerateEntry> enumerate(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerate(AbsPathView path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPathView path) const override;
|
||||
|
||||
ConvertToNativePathResult convertToNativePath(const AbsPath& path) const override;
|
||||
ConvertToNativePathResult convertToNativePath(AbsPathView path) const override;
|
||||
|
||||
protected:
|
||||
AbsPath convertToUnderlyingPath(const AbsPath& path) const;
|
||||
AbsPath convertToUnderlyingPath(AbsPathView path) const;
|
||||
tl::lent_ref<IFilesystem> m_filesystem;
|
||||
AbsPath m_location;
|
||||
};
|
||||
|
||||
+22
-22
@@ -44,7 +44,7 @@ using SetWriteTimeResult = tl::result<void, Error>;
|
||||
|
||||
struct EnumerateEntry
|
||||
{
|
||||
RelPath path;
|
||||
RelPathView path;
|
||||
bool isFolder = false;
|
||||
};
|
||||
|
||||
@@ -68,9 +68,9 @@ public:
|
||||
|
||||
//Opens a Read-only Stream
|
||||
//Searches for the stream in the packs from the mountpoint in top to bottom order, and opens if found
|
||||
virtual OpenSourceResult openSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const = 0;
|
||||
virtual OpenStreamSourceResult openStreamSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const = 0;
|
||||
virtual OpenMapSourceResult openMapSource(const AbsPath& path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const = 0;
|
||||
virtual OpenSourceResult openSource(AbsPathView path, SourceFlags flags = SourceFlags()) const = 0;
|
||||
virtual OpenStreamSourceResult openStreamSource(AbsPathView path, SourceFlags flags = SourceFlags()) const = 0;
|
||||
virtual OpenMapSourceResult openMapSource(AbsPathView path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const = 0;
|
||||
|
||||
using SinkFlag = ISink::Flag;
|
||||
using SinkFlags = ISink::Flags;
|
||||
@@ -79,46 +79,46 @@ public:
|
||||
//Searches for the stream in the packs from the mountpoint in top to bottom order, and opens if found.
|
||||
//If used with the CREATE flag, it will create the stream if not found.
|
||||
//NOTE: this will fail if the mountpoint has only read-only packs (zip files, etc)
|
||||
virtual OpenSinkResult openSink(const AbsPath& path, Mode mode, SinkFlags flags = SinkFlags()) = 0;
|
||||
virtual OpenStreamSinkResult openStreamSink(const AbsPath& path, Mode mode, SinkFlags flags = SinkFlags()) = 0;
|
||||
virtual OpenMapSinkResult openMapSink(const AbsPath& path, Mode mode, size_t size, SinkFlags flags = SinkFlags()) = 0;
|
||||
virtual OpenSinkResult openSink(AbsPathView path, Mode mode, SinkFlags flags = SinkFlags()) = 0;
|
||||
virtual OpenStreamSinkResult openStreamSink(AbsPathView path, Mode mode, SinkFlags flags = SinkFlags()) = 0;
|
||||
virtual OpenMapSinkResult openMapSink(AbsPathView path, Mode mode, size_t size, SinkFlags flags = SinkFlags()) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Returns the physical location of the virtual pack.
|
||||
virtual ConvertToNativePathResult convertToNativePath(const AbsPath& path) const = 0;
|
||||
virtual ConvertToNativePathResult convertToNativePath(AbsPathView path) const = 0;
|
||||
|
||||
virtual IsFileResult isFile(const AbsPath& path) const = 0;
|
||||
virtual IsFolderResult isFolder(const AbsPath& path) const = 0;
|
||||
virtual ExistsResult exists(const AbsPath& path) const = 0;
|
||||
virtual IsFileResult isFile(AbsPathView path) const = 0;
|
||||
virtual IsFolderResult isFolder(AbsPathView path) const = 0;
|
||||
virtual ExistsResult exists(AbsPathView path) const = 0;
|
||||
|
||||
virtual GetStatResult getStat(const AbsPath& path) const = 0;
|
||||
virtual GetStatResult getStat(AbsPathView path) const = 0;
|
||||
|
||||
virtual MakeFolderResult makeFolder(const AbsPath& path) = 0;
|
||||
virtual MakeFolderResult makeFolder(AbsPathView path) = 0;
|
||||
|
||||
virtual RenameResult rename(const AbsPath& path, const AbsPath& newPath) = 0;
|
||||
virtual RenameResult rename(AbsPathView path, AbsPathView newPath) = 0;
|
||||
|
||||
//this removes one file or one folder. The folder is removed ONLY if it's empty. If you want to remove a non-empty folder, use RemoveRecursively
|
||||
virtual RemoveResult remove(const AbsPath& path) = 0;
|
||||
virtual RemoveResult remove(AbsPathView path) = 0;
|
||||
|
||||
virtual CopyResult copy(const AbsPath& path, const AbsPath& newPath) = 0;
|
||||
virtual CopyResult copy(AbsPathView path, AbsPathView newPath) = 0;
|
||||
|
||||
// Hard links are essentially a new name for the same file data.
|
||||
// The file becomes reference counted and the data will be deleted when all handles to it are removed from the FS.
|
||||
virtual MakeHardLinkResult makeHardLink(const AbsPath& sourcePath, const AbsPath& linkPath) = 0;
|
||||
virtual MakeHardLinkResult makeHardLink(AbsPathView sourcePath, AbsPathView linkPath) = 0;
|
||||
|
||||
// Soft links are like 'weak' pointers to a file. If the original gets deleted the soft link becomes 'null'.
|
||||
virtual MakeSoftLinkResult makeSymLink(const AbsPath& sourcePath, const AbsPath& linkPath) = 0;
|
||||
virtual MakeSoftLinkResult makeSymLink(AbsPathView sourcePath, AbsPathView linkPath) = 0;
|
||||
|
||||
//Use this function in order to remove the set folder and all of the files and folders contained inside.
|
||||
//This function is not atomic; if the removal of any of the folders or files fails, the process will be stopped
|
||||
//and the function will return false, but any of the previously removed files will be already removed.
|
||||
virtual RemoveRecursivelyResult removeRecursively(const AbsPath& path) = 0;
|
||||
virtual RemoveRecursivelyResult removeRecursively(AbsPathView path) = 0;
|
||||
|
||||
virtual SetWriteTimeResult setWriteTime(const AbsPath& path, time_t time) = 0;
|
||||
virtual SetWriteTimeResult setWriteTime(AbsPathView path, time_t time) = 0;
|
||||
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerate(const AbsPath& path) const = 0;
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerateRecursively(const AbsPath& path) const = 0;
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerate(AbsPathView path) const = 0;
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPathView path) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -23,20 +23,20 @@ public:
|
||||
using SourceFlags = IFilesystem::SourceFlags;
|
||||
using MapView = IFilesystem::MapView;
|
||||
|
||||
virtual OpenSourceResult openSource(const AbsPath& i_path, SourceFlags i_flags = SourceFlags()) const = 0;
|
||||
virtual OpenStreamSourceResult openStreamSource(const AbsPath& i_path, SourceFlags i_flags = SourceFlags()) const = 0;
|
||||
virtual OpenMapSourceResult openMapSource(const AbsPath& i_path, MapView i_mapView = MapView(), SourceFlags i_flags = SourceFlags()) const = 0;
|
||||
virtual OpenSourceResult openSource(AbsPathView i_path, SourceFlags i_flags = SourceFlags()) const = 0;
|
||||
virtual OpenStreamSourceResult openStreamSource(AbsPathView i_path, SourceFlags i_flags = SourceFlags()) const = 0;
|
||||
virtual OpenMapSourceResult openMapSource(AbsPathView i_path, MapView i_mapView = MapView(), SourceFlags i_flags = SourceFlags()) const = 0;
|
||||
|
||||
virtual IsFileResult isFile(const AbsPath& i_path) const = 0;
|
||||
virtual IsFolderResult isFolder(const AbsPath& i_path) const = 0;
|
||||
virtual ExistsResult exists(const AbsPath& i_path) const = 0;
|
||||
virtual IsFileResult isFile(AbsPathView i_path) const = 0;
|
||||
virtual IsFolderResult isFolder(AbsPathView i_path) const = 0;
|
||||
virtual ExistsResult exists(AbsPathView i_path) const = 0;
|
||||
|
||||
virtual GetStatResult getStat(const AbsPath& i_path) const = 0;
|
||||
virtual GetStatResult getStat(AbsPathView i_path) const = 0;
|
||||
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerate(const AbsPath& i_path) const = 0;
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerateRecursively(const AbsPath& i_path) const = 0;
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerate(AbsPathView i_path) const = 0;
|
||||
virtual cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPathView i_path) const = 0;
|
||||
|
||||
virtual ConvertToNativePathResult convertToNativePath(const AbsPath& i_path) const = 0;
|
||||
virtual ConvertToNativePathResult convertToNativePath(AbsPathView i_path) const = 0;
|
||||
|
||||
protected:
|
||||
IPack() = default;
|
||||
|
||||
@@ -13,17 +13,17 @@ public:
|
||||
using SinkFlag = IFilesystem::SinkFlag;
|
||||
using SinkFlags = IFilesystem::SinkFlags;
|
||||
|
||||
virtual OpenSinkResult openSink(const AbsPath& i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) = 0;
|
||||
virtual OpenStreamSinkResult openStreamSink(const AbsPath& i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) = 0;
|
||||
virtual OpenMapSinkResult openMapSink(const AbsPath& i_path, Mode i_mode, size_t i_size, SinkFlags i_flags = SinkFlags()) = 0;
|
||||
virtual OpenSinkResult openSink(AbsPathView i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) = 0;
|
||||
virtual OpenStreamSinkResult openStreamSink(AbsPathView i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) = 0;
|
||||
virtual OpenMapSinkResult openMapSink(AbsPathView i_path, Mode i_mode, size_t i_size, SinkFlags i_flags = SinkFlags()) = 0;
|
||||
|
||||
virtual RemoveResult remove(const AbsPath& i_path) = 0;
|
||||
virtual RenameResult rename(const AbsPath& i_path, const AbsPath& i_newPath) = 0;
|
||||
virtual RemoveResult remove(AbsPathView i_path) = 0;
|
||||
virtual RenameResult rename(AbsPathView i_path, AbsPathView i_newPath) = 0;
|
||||
|
||||
virtual MakeFolderResult makeFolder(const AbsPath& i_path) = 0;
|
||||
virtual RemoveRecursivelyResult removeRecursively(const AbsPath& i_path) = 0;
|
||||
virtual MakeFolderResult makeFolder(AbsPathView i_path) = 0;
|
||||
virtual RemoveRecursivelyResult removeRecursively(AbsPathView i_path) = 0;
|
||||
|
||||
virtual SetWriteTimeResult setWriteTime(const AbsPath& i_path, time_t i_time) = 0;
|
||||
virtual SetWriteTimeResult setWriteTime(AbsPathView i_path, time_t i_time) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -21,46 +21,46 @@ public:
|
||||
NativeFilesystem() = default;
|
||||
explicit NativeFilesystem(CheckFlags checkFlags);
|
||||
|
||||
OpenSourceResult openSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(const AbsPath& path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
OpenSinkResult openSink(const AbsPath& path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenStreamSinkResult openStreamSink(const AbsPath& path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenMapSinkResult openMapSink(const AbsPath& path, Mode mode, size_t size, SinkFlags flags = SinkFlags()) override;
|
||||
OpenSourceResult openSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(AbsPathView path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
OpenSinkResult openSink(AbsPathView path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenStreamSinkResult openStreamSink(AbsPathView path, Mode mode, SinkFlags flags = SinkFlags()) override;
|
||||
OpenMapSinkResult openMapSink(AbsPathView path, Mode mode, size_t size, SinkFlags flags = SinkFlags()) override;
|
||||
|
||||
ConvertToNativePathResult convertToNativePath(const AbsPath& path) const override;
|
||||
ConvertToNativePathResult convertToNativePath(AbsPathView path) const override;
|
||||
|
||||
IsFileResult isFile(const AbsPath& path) const override;
|
||||
IsFolderResult isFolder(const AbsPath& path) const override;
|
||||
ExistsResult exists(const AbsPath& path) const override;
|
||||
IsFileResult isFile(AbsPathView path) const override;
|
||||
IsFolderResult isFolder(AbsPathView path) const override;
|
||||
ExistsResult exists(AbsPathView path) const override;
|
||||
|
||||
MakeFolderResult makeFolder(const AbsPath& path) override;
|
||||
MakeFolderResult makeFolder(AbsPathView path) override;
|
||||
|
||||
RenameResult rename(const AbsPath& path, const AbsPath& newPath) override;
|
||||
RenameResult rename(AbsPathView path, AbsPathView newPath) override;
|
||||
|
||||
RemoveResult remove(const AbsPath& path) override;
|
||||
RemoveRecursivelyResult removeRecursively(const AbsPath& path) override;
|
||||
RemoveResult remove(AbsPathView path) override;
|
||||
RemoveRecursivelyResult removeRecursively(AbsPathView path) override;
|
||||
|
||||
CopyResult copy(const AbsPath& path, const AbsPath& newPath) override;
|
||||
CopyResult copy(AbsPathView path, AbsPathView newPath) override;
|
||||
|
||||
MakeHardLinkResult makeHardLink(const AbsPath& sourcePath, const AbsPath& linkPath) override;
|
||||
MakeSoftLinkResult makeSymLink(const AbsPath& sourcePath, const AbsPath& linkPath) override;
|
||||
MakeHardLinkResult makeHardLink(AbsPathView sourcePath, AbsPathView linkPath) override;
|
||||
MakeSoftLinkResult makeSymLink(AbsPathView sourcePath, AbsPathView linkPath) override;
|
||||
|
||||
SetWriteTimeResult setWriteTime(const AbsPath& path, time_t time) override;
|
||||
SetWriteTimeResult setWriteTime(AbsPathView path, time_t time) override;
|
||||
|
||||
GetStatResult getStat(const AbsPath& path) const override;
|
||||
GetStatResult getStat(AbsPathView path) const override;
|
||||
|
||||
cppcoro::generator<EnumerateEntry> enumerate(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerate(AbsPathView path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPathView path) const override;
|
||||
|
||||
AbsPath getCurrentFolder() const;
|
||||
tl::result<Error> setCurrentFolder(const AbsPath& path);
|
||||
tl::result<Error> setCurrentFolder(AbsPathView path);
|
||||
|
||||
typedef tl::result<tl::vector<tl::string>, Error> EnumerateFilesResult;
|
||||
EnumerateFilesResult enumerateFiles(const AbsPath& fullPath) const;
|
||||
EnumerateFilesResult enumerateFiles(AbsPathView fullPath) const;
|
||||
|
||||
typedef tl::result<tl::vector<tl::string>, Error> EnumerateFoldersResult;
|
||||
EnumerateFoldersResult enumerateFolders(const AbsPath& fullPath) const;
|
||||
EnumerateFoldersResult enumerateFolders(AbsPathView fullPath) const;
|
||||
|
||||
AbsPath makeAbsPath(const tl::string& string) const;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace fs
|
||||
namespace native_utils
|
||||
{
|
||||
|
||||
bool validateCaseSensitiveFilename(const AbsPath& filePath) noexcept;
|
||||
bool validateCaseSensitiveFolder(const AbsPath& folderPath) noexcept;
|
||||
bool validateCaseSensitiveFilename(AbsPathView filePath) noexcept;
|
||||
bool validateCaseSensitiveFolder(AbsPathView folderPath) noexcept;
|
||||
|
||||
typedef eastl::fixed_string<wchar_t, 1024> wstring_t;
|
||||
typedef eastl::fixed_string<char, 1024> string_t;
|
||||
|
||||
@@ -13,8 +13,8 @@ FS_API ReadStreamResult readStream(tl::memory_buffer& buffer, IStreamSource& sou
|
||||
FS_API ReadStreamResult readStream(std::string& buffer, IStreamSource& source, size_t bufferSize = 0);
|
||||
FS_API ReadStreamResult readStream(eastl::string& buffer, IStreamSource& source, size_t bufferSize = 0);
|
||||
|
||||
FS_API ReadStreamResult readFile(tl::memory_buffer& buffer, IFilesystem& filesystem, const AbsPath& filePath, size_t bufferSize = 0);
|
||||
FS_API ReadStreamResult readFile(std::string& buffer, IFilesystem& filesystem, const AbsPath& filePath, size_t bufferSize = 0);
|
||||
FS_API ReadStreamResult readFile(eastl::string& buffer, IFilesystem& filesystem, const AbsPath& filePath, size_t bufferSize = 0);
|
||||
FS_API ReadStreamResult readFile(tl::memory_buffer& buffer, IFilesystem& filesystem, AbsPathView filePath, size_t bufferSize = 0);
|
||||
FS_API ReadStreamResult readFile(std::string& buffer, IFilesystem& filesystem, AbsPathView filePath, size_t bufferSize = 0);
|
||||
FS_API ReadStreamResult readFile(eastl::string& buffer, IFilesystem& filesystem, AbsPathView filePath, size_t bufferSize = 0);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,21 +12,21 @@ namespace fs
|
||||
class FS_API WritableFolderPack final : virtual public IWritablePack, public FolderPack
|
||||
{
|
||||
public:
|
||||
explicit WritableFolderPack(AbsPath location);
|
||||
WritableFolderPack(tl::lent_ref<IFilesystem> filesystem, AbsPath location);
|
||||
explicit WritableFolderPack(AbsPathView location);
|
||||
WritableFolderPack(tl::lent_ref<IFilesystem> filesystem, AbsPathView location);
|
||||
~WritableFolderPack() override = default;
|
||||
|
||||
OpenSinkResult openSink(const AbsPath& i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) override;
|
||||
OpenStreamSinkResult openStreamSink(const AbsPath& i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) override;
|
||||
OpenMapSinkResult openMapSink(const AbsPath& i_path, Mode i_mode, size_t i_size, SinkFlags i_flags = SinkFlags()) override;
|
||||
OpenSinkResult openSink(AbsPathView i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) override;
|
||||
OpenStreamSinkResult openStreamSink(AbsPathView i_path, Mode i_mode, SinkFlags i_flags = SinkFlags()) override;
|
||||
OpenMapSinkResult openMapSink(AbsPathView i_path, Mode i_mode, size_t i_size, SinkFlags i_flags = SinkFlags()) override;
|
||||
|
||||
RemoveResult remove(const AbsPath& i_path) override;
|
||||
RenameResult rename(const AbsPath& i_path, const AbsPath& i_newPath) override;
|
||||
RemoveResult remove(AbsPathView i_path) override;
|
||||
RenameResult rename(AbsPathView i_path, AbsPathView i_newPath) override;
|
||||
|
||||
MakeFolderResult makeFolder(const AbsPath& i_path) override;
|
||||
RemoveRecursivelyResult removeRecursively(const AbsPath& i_path) override;
|
||||
MakeFolderResult makeFolder(AbsPathView i_path) override;
|
||||
RemoveRecursivelyResult removeRecursively(AbsPathView i_path) override;
|
||||
|
||||
SetWriteTimeResult setWriteTime(const AbsPath& i_path, time_t i_time) override;
|
||||
SetWriteTimeResult setWriteTime(AbsPathView i_path, time_t i_time) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class FS_API DeflateFileWriter
|
||||
{
|
||||
public:
|
||||
//compression level: 0 to 9
|
||||
DeflateFileWriter(AbsPath i_filePath, tl::lent_ref<IFilesystem> i_filesystem, uint8_t i_compressionLevel);
|
||||
DeflateFileWriter(AbsPathView filePath, tl::lent_ref<IFilesystem> filesystem, uint8_t compressionLevel);
|
||||
|
||||
DeflateFileWriter(const DeflateFileWriter&) = delete;
|
||||
DeflateFileWriter& operator=(const DeflateFileWriter&) = delete;
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
DeflateFileWriter(DeflateFileWriter&&) = default;
|
||||
DeflateFileWriter& operator=(DeflateFileWriter&&) = default;
|
||||
|
||||
ZipWriter::DataWriterResult operator()(IStreamSink& i_sink);
|
||||
ZipWriter::DataWriterResult operator()(IStreamSink& sink);
|
||||
|
||||
private:
|
||||
AbsPath m_filePath;
|
||||
|
||||
@@ -15,7 +15,7 @@ class IFilesystem;
|
||||
class FS_API StoreFileWriter
|
||||
{
|
||||
public:
|
||||
StoreFileWriter(AbsPath i_filePath, tl::lent_ref<IFilesystem> i_filesystem);
|
||||
StoreFileWriter(AbsPathView filePath, tl::lent_ref<IFilesystem> filesystem);
|
||||
|
||||
StoreFileWriter(const StoreFileWriter&) = delete;
|
||||
StoreFileWriter& operator=(const StoreFileWriter&) = delete;
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
StoreFileWriter(StoreFileWriter&&) = default;
|
||||
StoreFileWriter& operator=(StoreFileWriter&&) = default;
|
||||
|
||||
ZipWriter::DataWriterResult operator()(IStreamSink& i_sink);
|
||||
ZipWriter::DataWriterResult operator()(IStreamSink& sink);
|
||||
|
||||
private:
|
||||
AbsPath m_filePath;
|
||||
|
||||
+13
-13
@@ -23,24 +23,24 @@ public:
|
||||
typedef tl::result<tl::unique_ref<ZipPack>, Error> CreateResult;
|
||||
|
||||
static CreateResult create(tl::unique_ref<IMapSource> zipFileSource);
|
||||
static CreateResult create(tl::lent_ref<const IFilesystem> filesystem, AbsPath zipFileLocation);
|
||||
static CreateResult create(tl::lent_ref<const IFilesystem> filesystem, AbsPathView zipFileLocation);
|
||||
|
||||
virtual void setEncryptionData(const tl::string& key, uint32_t rounds);
|
||||
|
||||
OpenSourceResult openSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(const AbsPath& path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(const AbsPath& path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
OpenSourceResult openSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenStreamSourceResult openStreamSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
|
||||
OpenMapSourceResult openMapSource(AbsPathView path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;
|
||||
|
||||
IsFileResult isFile(const AbsPath& path) const override;
|
||||
IsFolderResult isFolder(const AbsPath& path) const override;
|
||||
ExistsResult exists(const AbsPath& path) const override;
|
||||
IsFileResult isFile(AbsPathView path) const override;
|
||||
IsFolderResult isFolder(AbsPathView path) const override;
|
||||
ExistsResult exists(AbsPathView path) const override;
|
||||
|
||||
GetStatResult getStat(const AbsPath& path) const override;
|
||||
GetStatResult getStat(AbsPathView path) const override;
|
||||
|
||||
cppcoro::generator<EnumerateEntry> enumerate(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(const AbsPath& path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerate(AbsPathView path) const override;
|
||||
cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPathView path) const override;
|
||||
|
||||
tl::result<AbsPath, Error> convertToNativePath(const AbsPath& path) const override;
|
||||
tl::result<AbsPath, Error> convertToNativePath(AbsPathView path) const override;
|
||||
|
||||
protected:
|
||||
struct File;
|
||||
@@ -48,7 +48,7 @@ protected:
|
||||
struct EntryIndex;
|
||||
|
||||
ZipPack(tl::unique_ref<IMapSource> zipFileSource, ZipReader zipReader);
|
||||
ZipPack(tl::lent_ref<const IFilesystem> filesystem, AbsPath zipFileLocation, ZipReader zipReader);
|
||||
ZipPack(tl::lent_ref<const IFilesystem> filesystem, AbsPathView zipFileLocation, ZipReader zipReader);
|
||||
|
||||
OpenMapSourceResult openRawMapSource(const File& file, MapView mapView) const;
|
||||
OpenSourceResult openRawSource(const File& file) const;
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
OpenMapSourceResult openZipMapSource(const File& file) const;
|
||||
OpenStreamSourceResult openZipStreamSource(const File& file) const;
|
||||
|
||||
uint16_t getOrAddFolder(AbsPath folderPath, tl::vector<tl::vector<EntryIndex>>& io_childrenIndices);
|
||||
uint16_t getOrAddFolder(AbsPathView folderPath, tl::vector<tl::vector<EntryIndex>>& io_childrenIndices);
|
||||
void createEntries(ZipReader zipReader);
|
||||
|
||||
struct File
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace fs
|
||||
class ISink;
|
||||
|
||||
typedef tl::result<void, Error> UnzipResult;
|
||||
FS_API UnzipResult unzipSource(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::unique_ref<IMapSource> source);
|
||||
FS_API UnzipResult unzipFile(IFilesystem& dstFilesystem, const AbsPath& filePath, tl::lent_ref<const IFilesystem> filesystem, AbsPath srcFilePath);
|
||||
FS_API UnzipResult unzipSource(IFilesystem& dstFilesystem, AbsPathView filePath, tl::unique_ref<IMapSource> source);
|
||||
FS_API UnzipResult unzipFile(IFilesystem& dstFilesystem, AbsPathView filePath, tl::lent_ref<const IFilesystem> filesystem, AbsPathView srcFilePath);
|
||||
|
||||
typedef tl::result<void, Error> ZipResult;
|
||||
FS_API ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, const AbsPath& path, uint8_t compressionLevel, size_t fileDataAlignment = 0);
|
||||
FS_API ZipResult zipToFile(IFilesystem& dstFilesystem, const AbsPath& dstFilePath, tl::lent_ref<IFilesystem> filesystem, const AbsPath& path, uint8_t compressionLevel, size_t fileDataAlignment = 0);
|
||||
FS_API ZipResult zipToSink(ISink& sink, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel, size_t fileDataAlignment = 0);
|
||||
FS_API ZipResult zipToFile(IFilesystem& dstFilesystem, AbsPathView dstFilePath, tl::lent_ref<IFilesystem> filesystem, AbsPathView path, uint8_t compressionLevel, size_t fileDataAlignment = 0);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user