#pragma once #include "../string/String.hpp" #include namespace sprawl { namespace filesystem { char const* LineSeparator(); char const* NullDevice(); void Chdir(String const& path); String GetCwd(); enum class RelativeTo { Beginning, CurrentPosition, End, }; class File { public: File(FILE* file, sprawl::String const& mode) : m_file(file) , m_mode(mode) , m_refCount(new std::atomic(1)) { // } File() : m_file(nullptr) , m_mode() , m_refCount(nullptr) { // } File(File const& other); void operator=(File const& other); ~File(); void Close(); void Sync(); void Flush(); int FileNo(); bool IsATTY(); String Read(int numBytes = -1); String ReadLine(int numBytes = -1); void Seek(int offset, RelativeTo relativeTo); int Tell(); void Truncate(int size = -1); void Write(String const& str); bool IsClosed(); String const& Mode(); int FileSize(); private: FILE* m_file; String m_mode; std::atomic* m_refCount; }; File Open(String const& path, char const* const mode); /// @todo: bool Mkdir(String const& path, int mode); bool MakeDirs(String const& path, int mode); bool Remove(String const& path); bool RemoveDirs(String const& path); bool Rename(String const& path, String const& newName); bool Renames(String const& path, String const& newName); bool RmDir(String const& path); bool RmTree(String const& path); String TempName(String const& dir = "", String const& path = ""); /// @todo - access(), chmod(), chflags(), stat() /// @todo - environment variables, getpid, umask, listdir, lstat, readlink } }