2015-12-23 21:26:46 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class FileSystem : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
class File
|
|
|
|
{
|
|
|
|
public:
|
2016-06-06 07:00:48 -04:00
|
|
|
File() {};
|
2015-12-23 21:26:46 -05:00
|
|
|
File(std::string file) : FilePath(file) { this->Read(); };
|
|
|
|
|
2016-06-06 07:00:48 -04:00
|
|
|
bool Exists() { return !this->Buffer.empty(); };
|
2015-12-23 21:26:46 -05:00
|
|
|
std::string GetName() { return this->FilePath; };
|
|
|
|
std::string& GetBuffer() { return this->Buffer; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string FilePath;
|
|
|
|
std::string Buffer;
|
|
|
|
|
|
|
|
void Read();
|
|
|
|
};
|
|
|
|
|
2016-01-10 06:25:31 -05:00
|
|
|
class FileWriter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileWriter(std::string file) : FilePath(file), Handle(0) { this->Open(); };
|
|
|
|
~FileWriter() { this->Close(); };
|
|
|
|
|
|
|
|
void Write(std::string data);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int Handle;
|
|
|
|
std::string FilePath;
|
|
|
|
|
|
|
|
void Open();
|
|
|
|
void Close();
|
|
|
|
};
|
|
|
|
|
2016-08-15 10:40:30 -04:00
|
|
|
FileSystem();
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2015-12-23 21:26:46 -05:00
|
|
|
const char* GetName() { return "FileSystem"; };
|
2016-08-15 10:40:30 -04:00
|
|
|
#endif
|
2016-01-02 12:28:47 -05:00
|
|
|
|
2016-01-10 06:25:31 -05:00
|
|
|
static std::vector<std::string> GetFileList(std::string path, std::string extension);
|
2016-04-04 11:18:57 -04:00
|
|
|
static std::vector<std::string> GetSysFileList(std::string path, std::string extension, bool folders = false);
|
2016-01-10 06:25:31 -05:00
|
|
|
static void DeleteFile(std::string folder, std::string file);
|
|
|
|
|
2016-01-02 12:28:47 -05:00
|
|
|
private:
|
2016-06-06 07:00:48 -04:00
|
|
|
|
|
|
|
static void RegisterFolder(const char* folder);
|
|
|
|
|
|
|
|
static void RegisterFolders();
|
|
|
|
static void StartupStub();
|
2016-01-02 12:28:47 -05:00
|
|
|
static int ExecIsFSStub(const char* execFilename);
|
2015-12-23 21:26:46 -05:00
|
|
|
};
|
|
|
|
}
|