mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-02-08 15:55:46 +00:00
Make streams and vfs and http shared_ptr
This commit is contained in:
@@ -8,7 +8,7 @@ namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
public:
|
||||
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenFile(VFSPath path, std::string mode);
|
||||
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
@@ -35,6 +35,11 @@ namespace Tesses::Framework::Filesystem
|
||||
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
|
||||
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
|
||||
|
||||
bool StatVFS(VFSPath path, StatVFSData& vfsData);
|
||||
|
||||
void Chmod(VFSPath path, uint32_t mode);
|
||||
|
||||
|
||||
};
|
||||
extern LocalFilesystem LocalFS;
|
||||
extern std::shared_ptr<LocalFilesystem> LocalFS;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace Tesses::Framework::Filesystem
|
||||
MemoryEntry* GetEntry(VFSPath path,bool followSymlink);
|
||||
public:
|
||||
MemoryFilesystem();
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenFile(VFSPath path, std::string mode);
|
||||
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
|
||||
@@ -7,29 +7,28 @@ namespace Tesses::Framework::Filesystem
|
||||
class MountableDirectory {
|
||||
public:
|
||||
std::string name;
|
||||
VFS* vfs;
|
||||
std::shared_ptr<VFS> vfs;
|
||||
bool owns;
|
||||
std::vector<MountableDirectory*> dirs;
|
||||
void GetFS(VFSPath srcPath, VFSPath curDir, VFSPath& destRoot, VFSPath& destPath, VFS*& vfs);
|
||||
void GetFS(VFSPath srcPath, VFSPath curDir, VFSPath& destRoot, VFSPath& destPath, std::shared_ptr<VFS>& vfs);
|
||||
~MountableDirectory();
|
||||
};
|
||||
|
||||
class MountableFilesystem : public VFS
|
||||
{
|
||||
bool owns;
|
||||
VFS* root;
|
||||
std::shared_ptr<VFS> root;
|
||||
|
||||
std::vector<MountableDirectory*> directories;
|
||||
|
||||
void GetFS(VFSPath srcPath, VFSPath& destRoot, VFSPath& destPath, VFS*& vfs);
|
||||
void GetFS(VFSPath srcPath, VFSPath& destRoot, VFSPath& destPath, std::shared_ptr<VFS>& vfs);
|
||||
|
||||
|
||||
public:
|
||||
MountableFilesystem();
|
||||
MountableFilesystem(VFS* root, bool owns);
|
||||
void Mount(VFSPath path, VFS* fs, bool owns);
|
||||
MountableFilesystem(std::shared_ptr<VFS> root);
|
||||
void Mount(VFSPath path, std::shared_ptr<VFS> vfs);
|
||||
void Unmount(VFSPath path);
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool SpecialFileExists(VFSPath path);
|
||||
@@ -53,5 +52,10 @@ namespace Tesses::Framework::Filesystem
|
||||
~MountableFilesystem();
|
||||
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
|
||||
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
|
||||
|
||||
bool StatVFS(VFSPath path, StatVFSData& vfsData);
|
||||
|
||||
void Chmod(VFSPath path, uint32_t mode);
|
||||
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace Tesses::Framework::Filesystem
|
||||
class NullFilesystem : public VFS
|
||||
{
|
||||
public:
|
||||
Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool RegularFileExists(VFSPath path);
|
||||
|
||||
@@ -6,14 +6,13 @@ namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class SubdirFilesystem : public VFS
|
||||
{
|
||||
bool owns;
|
||||
VFS* parent;
|
||||
std::shared_ptr<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);
|
||||
SubdirFilesystem(std::shared_ptr<VFS> parent, VFSPath path);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenFile(VFSPath path, std::string mode);
|
||||
void CreateDirectory(VFSPath path);
|
||||
void DeleteDirectory(VFSPath path);
|
||||
bool SpecialFileExists(VFSPath path);
|
||||
@@ -38,6 +37,9 @@ namespace Tesses::Framework::Filesystem
|
||||
~SubdirFilesystem();
|
||||
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
|
||||
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
|
||||
|
||||
bool StatVFS(VFSPath path, StatVFSData& vfsData);
|
||||
|
||||
void Chmod(VFSPath path, uint32_t mode);
|
||||
|
||||
};
|
||||
}
|
||||
@@ -8,6 +8,20 @@
|
||||
|
||||
namespace Tesses::Framework::Filesystem
|
||||
{
|
||||
class StatVFSData {
|
||||
public:
|
||||
uint64_t BlockSize;
|
||||
uint64_t FragmentSize;
|
||||
uint64_t Blocks;
|
||||
uint64_t BlocksFree;
|
||||
uint64_t BlocksAvailable;
|
||||
uint64_t TotalInodes;
|
||||
uint64_t FreeInodes;
|
||||
uint64_t AvailableInodes;
|
||||
uint64_t Id;
|
||||
uint64_t Flags;
|
||||
uint64_t MaxNameLength;
|
||||
};
|
||||
class VFSPath {
|
||||
public:
|
||||
static VFSPath CurrentDirectoryAsRelative();
|
||||
@@ -107,7 +121,7 @@ namespace Tesses::Framework::Filesystem
|
||||
class VFS {
|
||||
public:
|
||||
|
||||
virtual Tesses::Framework::Streams::Stream* OpenFile(VFSPath path, std::string mode)=0;
|
||||
virtual std::shared_ptr<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;
|
||||
@@ -134,6 +148,10 @@ namespace Tesses::Framework::Filesystem
|
||||
virtual void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
|
||||
virtual void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
|
||||
|
||||
virtual bool StatVFS(VFSPath path, StatVFSData& data);
|
||||
|
||||
virtual void Chmod(VFSPath path, uint32_t mode);
|
||||
|
||||
virtual ~VFS();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user