first commit
This commit is contained in:
28
include/TessesFramework/Filesystem/LocalFS.hpp
Normal file
28
include/TessesFramework/Filesystem/LocalFS.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "VFS.hpp"
|
||||
namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class LocalFilesystem : public VFS
|
||||
{
|
||||
public:
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool RegularFileExists(VFSPath path);
|
||||
bool SymlinkExists(VFSPath path);
|
||||
bool CharacterDeviceExists(VFSPath path);
|
||||
bool BlockDeviceExists(VFSPath path);
|
||||
bool SocketFileExists(VFSPath path);
|
||||
bool FIFOFileExists(VFSPath path);
|
||||
bool DirectoryExists(VFSPath path);
|
||||
void DeleteFile(VFSPath path);
|
||||
void CreateSymlink(VFSPath existingFile, VFSPath symlinkFile);
|
||||
void GetPaths(VFSPath path, std::vector<VFSPath>& paths);
|
||||
void CreateHardlink(VFSPath existingFile, VFSPath newName);
|
||||
void MoveFile(VFSPath src, VFSPath dest);
|
||||
void MoveDirectory(VFSPath src, VFSPath dest);
|
||||
VFSPath ReadLink(VFSPath path);
|
||||
std::string VFSPathToSystem(VFSPath path);
|
||||
VFSPath SystemToVFSPath(std::string path);
|
||||
};
|
||||
}
|
||||
53
include/TessesFramework/Filesystem/MountableFilesystem.hpp
Normal file
53
include/TessesFramework/Filesystem/MountableFilesystem.hpp
Normal file
@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#include "VFS.hpp"
|
||||
namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class MountableDirectory {
|
||||
public:
|
||||
std::string name;
|
||||
VFS* vfs;
|
||||
bool owns;
|
||||
std::vector<MountableDirectory*> dirs;
|
||||
void GetFS(VFSPath srcPath, VFSPath curDir, VFSPath& destRoot, VFSPath& destPath, VFS*& vfs);
|
||||
~MountableDirectory();
|
||||
};
|
||||
|
||||
class MountableFilesystem : public VFS
|
||||
{
|
||||
bool owns;
|
||||
VFS* root;
|
||||
|
||||
std::vector<MountableDirectory*> directories;
|
||||
|
||||
void GetFS(VFSPath srcPath, VFSPath& destRoot, VFSPath& destPath, VFS*& vfs);
|
||||
|
||||
|
||||
public:
|
||||
MountableFilesystem();
|
||||
MountableFilesystem(VFS* root, bool owns);
|
||||
void Mount(VFSPath path, VFS* fs, bool owns);
|
||||
void Unmount(VFSPath path);
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool SpecialFileExists(VFSPath path);
|
||||
bool FileExists(VFSPath path);
|
||||
bool RegularFileExists(VFSPath path);
|
||||
bool SymlinkExists(VFSPath path);
|
||||
bool CharacterDeviceExists(VFSPath path);
|
||||
bool BlockDeviceExists(VFSPath path);
|
||||
bool SocketFileExists(VFSPath path);
|
||||
bool FIFOFileExists(VFSPath path);
|
||||
bool DirectoryExists(VFSPath path);
|
||||
void DeleteFile(VFSPath path);
|
||||
void CreateSymlink(VFSPath existingFile, VFSPath symlinkFile);
|
||||
void GetPaths(VFSPath path, std::vector<VFSPath>& paths);
|
||||
void CreateHardlink(VFSPath existingFile, VFSPath newName);
|
||||
void MoveFile(VFSPath src, VFSPath dest);
|
||||
void MoveDirectory(VFSPath src, VFSPath dest);
|
||||
VFSPath ReadLink(VFSPath path);
|
||||
std::string VFSPathToSystem(VFSPath path);
|
||||
VFSPath SystemToVFSPath(std::string path);
|
||||
~MountableFilesystem();
|
||||
};
|
||||
}
|
||||
19
include/TessesFramework/Filesystem/NullFilesystem.hpp
Normal file
19
include/TessesFramework/Filesystem/NullFilesystem.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "VFS.hpp"
|
||||
namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class NullFilesystem : public VFS
|
||||
{
|
||||
public:
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool RegularFileExists(VFSPath path);
|
||||
bool DirectoryExists(VFSPath path);
|
||||
void DeleteFile(VFSPath path);
|
||||
void GetPaths(VFSPath path, std::vector<VFSPath>& paths);
|
||||
void MoveFile(VFSPath src, VFSPath dest);
|
||||
std::string VFSPathToSystem(VFSPath path);
|
||||
VFSPath SystemToVFSPath(std::string path);
|
||||
};
|
||||
}
|
||||
38
include/TessesFramework/Filesystem/SubdirFilesystem.hpp
Normal file
38
include/TessesFramework/Filesystem/SubdirFilesystem.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "VFS.hpp"
|
||||
namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class SubdirFilesystem : public VFS
|
||||
{
|
||||
bool owns;
|
||||
VFS* parent;
|
||||
VFSPath path;
|
||||
VFSPath ToParent(VFSPath path);
|
||||
VFSPath FromParent(VFSPath path);
|
||||
public:
|
||||
SubdirFilesystem(VFS* parent, VFSPath path, bool owns);
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool SpecialFileExists(VFSPath path);
|
||||
bool FileExists(VFSPath path);
|
||||
bool RegularFileExists(VFSPath path);
|
||||
bool SymlinkExists(VFSPath path);
|
||||
bool CharacterDeviceExists(VFSPath path);
|
||||
bool BlockDeviceExists(VFSPath path);
|
||||
bool SocketFileExists(VFSPath path);
|
||||
bool FIFOFileExists(VFSPath path);
|
||||
bool DirectoryExists(VFSPath path);
|
||||
void DeleteFile(VFSPath path);
|
||||
void CreateSymlink(VFSPath existingFile, VFSPath symlinkFile);
|
||||
void GetPaths(VFSPath path, std::vector<VFSPath>& paths);
|
||||
void CreateHardlink(VFSPath existingFile, VFSPath newName);
|
||||
void MoveFile(VFSPath src, VFSPath dest);
|
||||
void MoveDirectory(VFSPath src, VFSPath dest);
|
||||
void DeleteDirectoryRecurse(VFSPath path);
|
||||
VFSPath ReadLink(VFSPath path);
|
||||
std::string VFSPathToSystem(VFSPath path);
|
||||
VFSPath SystemToVFSPath(std::string path);
|
||||
~SubdirFilesystem();
|
||||
};
|
||||
}
|
||||
50
include/TessesFramework/Filesystem/VFS.hpp
Normal file
50
include/TessesFramework/Filesystem/VFS.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "../Common.hpp"
|
||||
#include "../Streams/Stream.hpp"
|
||||
namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class VFSPath {
|
||||
public:
|
||||
static VFSPath RelativeCurrentDirectory();
|
||||
bool relative;
|
||||
static std::vector<std::string> SplitPath(std::string path,bool native=false);
|
||||
std::vector<std::string> path;
|
||||
VFSPath();
|
||||
VFSPath(std::vector<std::string> path);
|
||||
VFSPath(std::string path);
|
||||
VFSPath(VFSPath p, std::string subent);
|
||||
VFSPath(VFSPath p, VFSPath p2);
|
||||
VFSPath GetParent();
|
||||
VFSPath CollapseRelativeParents();
|
||||
std::string GetFileName();
|
||||
std::string ToString();
|
||||
};
|
||||
class VFS {
|
||||
public:
|
||||
|
||||
virtual Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode)=0;
|
||||
virtual void CreateDirectory(VFSPath path)=0;
|
||||
virtual void DeleteDirectory(VFSPath path)=0;
|
||||
virtual bool RegularFileExists(VFSPath path)=0;
|
||||
virtual bool SymlinkExists(VFSPath path);
|
||||
virtual bool CharacterDeviceExists(VFSPath path);
|
||||
virtual bool BlockDeviceExists(VFSPath path);
|
||||
virtual bool SocketFileExists(VFSPath path);
|
||||
virtual bool FIFOFileExists(VFSPath path);
|
||||
virtual bool FileExists(VFSPath path);
|
||||
virtual bool SpecialFileExists(VFSPath path);
|
||||
virtual void CreateSymlink(VFSPath existingFile, VFSPath symlinkFile);
|
||||
virtual void CreateHardlink(VFSPath existingFile, VFSPath newName);
|
||||
virtual bool DirectoryExists(VFSPath path)=0;
|
||||
virtual void DeleteFile(VFSPath path)=0;
|
||||
virtual void DeleteDirectoryRecurse(VFSPath path);
|
||||
virtual void GetPaths(VFSPath path, std::vector<VFSPath>& paths)=0;
|
||||
virtual void MoveFile(VFSPath src, VFSPath dest)=0;
|
||||
virtual void MoveDirectory(VFSPath src, VFSPath dest);
|
||||
virtual VFSPath ReadLink(VFSPath path);
|
||||
virtual std::string VFSPathToSystem(VFSPath path)=0;
|
||||
virtual VFSPath SystemToVFSPath(std::string path)=0;
|
||||
|
||||
virtual ~VFS();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user