Using PathView to pass paths to APIs

This commit is contained in:
catalinvasile
2024-07-10 13:31:12 +02:00
parent d1ebc32f9d
commit 28b74b4056
499 changed files with 99851 additions and 300 deletions
+25 -25
View File
@@ -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);
};