Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum class Mode : int{
- NO=0, //Nothing
- NOB, //Nothing, binary
- RO, //Read-only
- ROB, //Read-only binary
- WO, //Write-only
- WOB, //Write-only binary
- RW, //Read-write
- RWB, //Read-write binary
- EXE //load program
- };
- enum /*throwable*/ class FError : int {
- SUCCESS=0,
- NO_SUCH_FILE,
- NO_PERMISSIONS,
- STILL_OPEN,
- WRITE_PROTECTED,
- READ_PROTECTED,
- NOT_EXECUTABLE,
- NO_SUCH_DEVICE,
- UNKNOWN,
- WRONG_ARCH,
- BUG_REPORT_PLS,
- MOD_UNLOADED,
- NO_COLOR
- };
- class File;
- class Directory;
- class FS {
- friend class File;
- friend class Directory;
- protected:
- Block dev;
- vector<File> openFiles;
- public:
- auto open(String &fname, Mode mode) -> File &;
- //Files are closed when deconstructed
- auto enter(String &dname) -> Directory &;
- auto create(String &fname) -> File &; //Created files are already opened RW
- auto delete(String &fname) -> bool;
- auto deleteDir(String &dname) -> bool;
- };
- class File {
- private:
- String fname;
- fsize_t size;
- fsize_t woff;
- fsize_t roff;
- friend class FS;
- Mode mode;
- File() {}
- File(String &name, Mode mode);
- public:
- auto read(fsize_t len, void *buf) -> fsize_t;
- auto write(fsize_t len, void *buf) -> fsize_t;
- template<typename T>
- auto operator>>(T& obj) -> File & {
- read(sizeof(T), (void*)&obj);
- return *this;
- }
- template<typename T>
- auto operator<<(T& obj) -> File & {
- write(sizeof(T), (void*)&obj);
- return *this;
- }
- auto getSize() -> fsize_t;
- auto seek(fsize_t sval) -> File &; //From beginning
- auto seek(foff_t off) -> File&; //Relative
- //And more?
- ~File();
- };
- class Directory:public Vector<File> {
- //Todo
- };
Advertisement
Add Comment
Please, Sign In to add comment