Change html to dark mode by default and stat in vfs

This commit is contained in:
2026-04-19 23:07:17 -05:00
parent 5435280209
commit c5cf13e1b7
40 changed files with 1110 additions and 1956 deletions

View File

@@ -1,50 +1,46 @@
#pragma once
#include "VFS.hpp"
#include "VFSFix.hpp"
namespace Tesses::Framework::Filesystem
{
class LocalFilesystem : public VFS
{
public:
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);
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);
VFSPathEnumerator EnumeratePaths(VFSPath path);
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);
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
bool Stat(VFSPath path, StatData& stat);
bool StatVFS(VFSPath path, StatVFSData& vfsData);
void Chmod(VFSPath path, uint32_t mode);
void Chown(VFSPath path, uint32_t uid, uint32_t gid);
void Lock(VFSPath path);
void Unlock(VFSPath path);
FIFOCreationResult CreateFIFO(VFSPath path, uint32_t mod);
protected:
std::shared_ptr<FSWatcher> CreateWatcher(std::shared_ptr<VFS> vfs, VFSPath path);
};
};
extern std::shared_ptr<LocalFilesystem> LocalFS;
}
}

View File

@@ -1,100 +0,0 @@
#pragma once
#include "VFS.hpp"
#include "VFSFix.hpp"
#include "../Threading/Mutex.hpp"
#include <atomic>
namespace Tesses::Framework::Filesystem
{
class MemoryEntry {
public:
std::string name;
virtual ~MemoryEntry();
};
class MemoryFileData {
public:
MemoryFileData();
Date::DateTime lastWrite;
bool canAccess;
size_t readers;
std::vector<uint8_t> file;
};
class MemoryFile : public MemoryEntry
{
public:
std::shared_ptr<MemoryFileData> data;
~MemoryFile();
};
class MemoryDirectory : public MemoryEntry
{
public:
MemoryDirectory();
Date::DateTime lastWrite;
std::vector<MemoryEntry*> entries;
~MemoryDirectory();
};
class MemorySymlink : public MemoryEntry
{
public:
Date::DateTime lastWrite;
VFSPath linkedTo;
};
class MemoryFilesystemStream : public Streams::Stream
{
public:
std::shared_ptr<Tesses::Framework::Threading::Mutex> mtx;
std::shared_ptr<MemoryFileData> data;
bool canRead;
bool canWrite;
bool canSeek;
int64_t pos;
MemoryFilesystemStream(std::shared_ptr<Tesses::Framework::Threading::Mutex> mtx, std::shared_ptr<MemoryFileData> data,bool canRead, bool canWrite, bool canSeek);
size_t Read(uint8_t* buff, size_t sz);
size_t Write(const uint8_t* buff, size_t sz);
bool CanRead();
bool CanWrite();
bool CanSeek();
int64_t GetPosition();
void Flush();
void Seek(int64_t pos, Streams::SeekOrigin whence);
~MemoryFilesystemStream();
};
class MemoryFilesystem : public VFS
{
std::shared_ptr<Tesses::Framework::Threading::Mutex> mtx;
MemoryDirectory root;
MemoryEntry* GetEntry(VFSPath path,bool followSymlink);
public:
MemoryFilesystem();
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);
bool SymlinkExists(VFSPath path);
bool DirectoryExists(VFSPath path);
void DeleteFile(VFSPath path);
void CreateSymlink(VFSPath existingFile, VFSPath symlinkFile);
VFSPathEnumerator EnumeratePaths(VFSPath path);
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);
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
~MemoryFilesystem();
};
};

View File

@@ -1,7 +1,7 @@
#pragma once
#include "VFS.hpp"
#include "VFSFix.hpp"
namespace Tesses::Framework::Filesystem
{
class MountableDirectory {
@@ -19,10 +19,10 @@ namespace Tesses::Framework::Filesystem
std::shared_ptr<VFS> root;
std::vector<MountableDirectory*> directories;
void GetFS(VFSPath srcPath, VFSPath& destRoot, VFSPath& destPath, std::shared_ptr<VFS>& vfs);
public:
MountableFilesystem();
MountableFilesystem(std::shared_ptr<VFS> root);
@@ -31,15 +31,7 @@ namespace Tesses::Framework::Filesystem
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);
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);
bool Stat(VFSPath path, StatData& data);
void DeleteFile(VFSPath path);
void CreateSymlink(VFSPath existingFile, VFSPath symlinkFile);
VFSPathEnumerator EnumeratePaths(VFSPath path);
@@ -50,14 +42,18 @@ namespace Tesses::Framework::Filesystem
std::string VFSPathToSystem(VFSPath path);
VFSPath SystemToVFSPath(std::string path);
~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);
void Chown(VFSPath path, uint32_t uid, uint32_t gid);
FIFOCreationResult CreateFIFO(VFSPath path, uint32_t mode);
void Lock(VFSPath path);
void Unlock(VFSPath path);
};
}
}

View File

@@ -1,21 +1,16 @@
#pragma once
#include "VFS.hpp"
#include "VFSFix.hpp"
namespace Tesses::Framework::Filesystem
{
class NullFilesystem : public VFS
{
public:
public:
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);
bool DirectoryExists(VFSPath path);
void DeleteFile(VFSPath path);
VFSPathEnumerator EnumeratePaths(VFSPath path);
void MoveFile(VFSPath src, VFSPath dest);
bool Stat(VFSPath path, StatData& data);
std::string VFSPathToSystem(VFSPath path);
VFSPath SystemToVFSPath(std::string path);
};
}
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include "VFS.hpp"
#include "VFSFix.hpp"
namespace Tesses::Framework::Filesystem
{
class SubdirFilesystem : public VFS
@@ -15,15 +15,6 @@ namespace Tesses::Framework::Filesystem
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);
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);
VFSPathEnumerator EnumeratePaths(VFSPath path);
@@ -35,13 +26,14 @@ namespace Tesses::Framework::Filesystem
std::string VFSPathToSystem(VFSPath path);
VFSPath SystemToVFSPath(std::string path);
~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);
bool Stat(VFSPath path, StatData& data);
void Chown(VFSPath path, uint32_t uid, uint32_t gid);
void Chmod(VFSPath path, uint32_t mode);
FIFOCreationResult CreateFIFO(VFSPath path, uint32_t mode);
void Lock(VFSPath path);
void Unlock(VFSPath path);
};
}
}

View File

@@ -2,7 +2,7 @@
#include "../Common.hpp"
#include "VFS.hpp"
#include "VFSFix.hpp"
namespace Tesses::Framework::Filesystem
namespace Tesses::Framework::Filesystem
{
void UniqueString(std::string& text);
@@ -20,15 +20,6 @@ namespace Tesses::Framework::Filesystem
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);
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);
VFSPathEnumerator EnumeratePaths(VFSPath path);
@@ -39,16 +30,19 @@ namespace Tesses::Framework::Filesystem
VFSPath ReadLink(VFSPath path);
std::string VFSPathToSystem(VFSPath path);
VFSPath SystemToVFSPath(std::string path);
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);
bool Stat(VFSPath path, StatData& data);
void Chmod(VFSPath path, uint32_t mode);
void Chown(VFSPath path, uint32_t uid, uint32_t gid);
FIFOCreationResult CreateFIFO(VFSPath path, uint32_t mode);
void Close();
void Lock(VFSPath path);
void Unlock(VFSPath path);
~TempFS();
};
}
}

View File

@@ -1,16 +1,18 @@
#pragma once
#include "../Common.hpp"
#include "../Streams/Stream.hpp"
#include <TessesFramework/Common.hpp>
#include <TessesFramework/Date/Date.hpp>
#include <functional>
#include <memory>
#include "../Date/Date.hpp"
#include "VFSFix.hpp"
namespace Tesses::Framework::Filesystem
{
class StatVFSData {
public:
struct StatVFSData {
uint64_t BlockSize;
uint64_t FragmentSize;
uint64_t Blocks;
@@ -23,12 +25,94 @@ namespace Tesses::Framework::Filesystem
uint64_t Flags;
uint64_t MaxNameLength;
};
constexpr uint32_t MODE_USER_READ = 0400;
constexpr uint32_t MODE_USER_WRITE = 0200;
constexpr uint32_t MODE_USER_EXEC = 0100;
constexpr uint32_t MODE_GROUP_READ = (MODE_USER_READ >> 3);
constexpr uint32_t MODE_GROUP_WRITE = (MODE_USER_WRITE >> 3);
constexpr uint32_t MODE_GROUP_EXEC = (MODE_USER_EXEC >> 3);
constexpr uint32_t MODE_OTHER_READ = (MODE_GROUP_READ >> 3);
constexpr uint32_t MODE_OTHER_WRITE = (MODE_GROUP_WRITE >> 3);
constexpr uint32_t MODE_OTHER_EXEC = (MODE_GROUP_EXEC >> 3);
constexpr uint32_t MODE_REGULAR = 0100000;
constexpr uint32_t MODE_DIRECTORY = 0040000;
constexpr uint32_t MODE_CHAR_DEVICE = 0020000;
constexpr uint32_t MODE_BLOCK_DEVICE = 0060000;
constexpr uint32_t MODE_SOCKET = 0140000;
constexpr uint32_t MODE_FIFO = 0010000;
constexpr uint32_t MODE_SYMLINK = 0120000;
struct StatData {
uint64_t Device;
uint64_t Inode;
uint32_t Mode;
uint64_t HardLinks;
uint32_t UserId;
uint32_t GroupId;
uint64_t DeviceId;
uint64_t Size;
uint64_t BlockSize;
uint64_t BlockCount;
Date::DateTime LastAccess;
Date::DateTime LastModified;
Date::DateTime LastStatus;
bool IsRegularFile()
{
return (Mode & MODE_REGULAR) > 0;
}
bool IsDirectory()
{
return (Mode & MODE_DIRECTORY) > 0;
}
bool IsCharDevice()
{
return (Mode & MODE_CHAR_DEVICE) > 0;
}
bool IsBlockDevice()
{
return (Mode & MODE_BLOCK_DEVICE) > 0;
}
bool IsSocket()
{
return (Mode & MODE_SOCKET) > 0;
}
bool IsFIFO()
{
return (Mode & MODE_FIFO) > 0;
}
bool IsSymlink()
{
return (Mode & MODE_SYMLINK) > 0;
}
bool IsSpecial()
{
if(IsRegularFile()) return false;
if(IsDirectory()) return false;
return true;
}
std::string ToSizeString(bool usesBin=true)
{
return TF_FileSize(this->Size, usesBin);
}
};
class VFSPath {
public:
static VFSPath CurrentDirectoryAsRelative();
bool relative;
static std::vector<std::string> SplitPath(std::string path);
std::vector<std::string> path;
std::vector<std::string> path;
VFSPath();
explicit VFSPath(const char* path) : VFSPath(std::string(path))
{}
@@ -36,7 +120,7 @@ namespace Tesses::Framework::Filesystem
VFSPath(std::string path);
VFSPath(VFSPath p, std::string subent);
VFSPath(VFSPath p, VFSPath p2);
//does not check for ?
static VFSPath ParseUriPath(std::string path);
@@ -52,7 +136,7 @@ namespace Tesses::Framework::Filesystem
static VFSPath GetAbsoluteCurrentDirectory();
static void SetAbsoluteCurrentDirectory(VFSPath path);
VFSPath MakeAbsolute() const;
VFSPath MakeAbsolute(VFSPath curDir) const;
VFSPath MakeRelative() const;
VFSPath MakeRelative(VFSPath toMakeRelativeTo) const;
@@ -98,10 +182,10 @@ namespace Tesses::Framework::Filesystem
VFSPathEnumeratorItterator& operator++();
VFSPathEnumeratorItterator& operator++(int);
VFSPath& operator*();
VFSPath* operator->();
bool operator!=(VFSPathEnumeratorItterator right);
bool operator==(VFSPathEnumeratorItterator right);
};
@@ -185,48 +269,60 @@ namespace Tesses::Framework::Filesystem
std::shared_ptr<VFS> GetFilesystem();
const VFSPath& GetPath();
virtual ~FSWatcher() = default;
static std::shared_ptr<FSWatcher> Create(std::shared_ptr<VFS> vfs, VFSPath path);
static std::shared_ptr<FSWatcher> Create(std::shared_ptr<VFS> vfs, VFSPath path);
};
enum class FIFOCreationResult {
Success=0,
Exists = 1,
ReadOnlyFS = 2,
Denied = 3,
OutOfInodes = 4,
UnknownError = 5,
Unsupported = 255
};
class VFS {
public:
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;
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 CreateDirectory(VFSPath path);
virtual void DeleteDirectory(VFSPath path);
bool DirectoryExists(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 FileExists(VFSPath path);
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 DeleteFile(VFSPath path);
virtual void DeleteDirectoryRecurse(VFSPath path);
virtual VFSPathEnumerator EnumeratePaths(VFSPath path) = 0;
virtual void MoveFile(VFSPath src, VFSPath dest)=0;
virtual void MoveFile(VFSPath src, VFSPath dest);
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 void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
virtual void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
virtual bool Stat(VFSPath path, StatData& data) = 0;
virtual bool StatVFS(VFSPath path, StatVFSData& data);
virtual void Chmod(VFSPath path, uint32_t mode);
virtual void Chown(VFSPath path, uint32_t userId, uint32_t groupId);
virtual void Lock(VFSPath path);
virtual void Unlock(VFSPath path);
virtual FIFOCreationResult CreateFIFO(VFSPath path, uint32_t mode);
virtual ~VFS();
virtual void Close();
@@ -236,7 +332,6 @@ namespace Tesses::Framework::Filesystem
friend class FSWatcher;
};
namespace Literals
{
@@ -246,4 +341,3 @@ namespace Tesses::Framework::Filesystem
}
}
}