-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathManager.h
More file actions
71 lines (52 loc) · 1.7 KB
/
Copy pathManager.h
File metadata and controls
71 lines (52 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <mutex>
#include <VFSManager.h>
namespace vfs
{
class ManagerServer : public vfs::Manager
{
private:
struct MountedDevice
{
fwRefContainer<Device> device;
std::string absolutePath;
std::string canonicalPath;
bool resolvesThroughLink = false;
};
struct MountPoint
{
std::string prefix;
mutable std::vector<MountedDevice> devices; // mutable? MUTABLE? is this Rust?!
};
// sorts mount points based on longest prefix
struct MountPointComparator
{
inline bool operator()(const MountPoint& left, const MountPoint& right) const
{
size_t lengthLeft = left.prefix.length();
size_t lengthRight = right.prefix.length();
if (lengthLeft == lengthRight)
{
return (left.prefix < right.prefix);
}
return (lengthLeft > lengthRight);
}
};
private:
std::set<MountPoint, MountPointComparator> m_mounts;
std::recursive_mutex m_mountMutex;
bool m_hasCanonicalPathMounts = false;
// fallback device - usually a local file system implementation
fwRefContainer<vfs::Device> m_fallbackDevice;
public:
ManagerServer();
public:
virtual fwRefContainer<Device> GetDevice(const std::string& path) override;
virtual fwRefContainer<Device> FindDevice(const std::string& absolutePath, std::string& transformedPath) override;
virtual fwRefContainer<Device> GetNativeDevice(void* nativeDevice) override;
virtual fwRefContainer<Device> FindDevice(const std::string& absolutePath, std::string& transformedPath, const std::string& preferredMountPrefix) override;
virtual void Mount(fwRefContainer<Device> device, const std::string& path) override;
virtual void Unmount(const std::string& path) override;
};
std::string MakeMemoryFilename(const void* buffer, size_t size);
}