#pragma once #include "Core.h" #include "String.h" #include #include #include #include namespace Nuake { class FileDialog { public: static std::string OpenFile(const char* filter); static std::string SaveFile(const char* filter); }; class Directory; class File; class FileSystem { public: static std::string Root; static Ref RootDirectory; static void SetRootDirectory(const std::string path); static void Scan(); static std::string AbsoluteToRelative(const std::string& path); static Ref GetFileTree(); static Ref GetFile(const std::string& path); static std::string GetFileNameFromPath(const std::string& path); static void ScanDirectory(Ref directory); static void GetDirectories(); static bool DirectoryExists(const std::string path); static bool FileExists(const std::string path, bool absolute = false); static std::string ReadFile(const std::string& path, bool absolute = false); static std::ofstream fileWriter; static bool BeginWriteFile(const std::string path); static bool WriteLine(const std::string line); static void EndWriteFile(); static int RemoveFile(const std::string& path); }; class File { private: std::string Type; std::string Name; std::string RelativePath; std::string AbsolutePath; Ref Parent; public: std::string GetExtension() { return Type; } std::string GetName() { return Name; } std::string GetRelativePath() { return RelativePath; } std::string GetAbsolutePath() { return AbsolutePath; } Ref GetParent() { return Parent; } std::string Read() { return FileSystem::ReadFile(AbsolutePath); } File(Ref parentDir, const std::string& absolutePath, const std::string& name, const std::string& type) { AbsolutePath = absolutePath; Parent = parentDir; RelativePath = FileSystem::AbsoluteToRelative(absolutePath); Name = name; Type = type; } }; class Directory { public: std::string name; std::string fullPath; Ref Parent; std::vector> Directories; std::vector> Files; }; }