1 //---------------------------------------------------------------------------- 2 // EDGE Filesystem API 3 //---------------------------------------------------------------------------- 4 // 5 // Copyright (c) 2003-2008 The EDGE Team. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 2 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 //---------------------------------------------------------------------------- 18 19 #ifndef __EPI_FILESYSTEM_H__ 20 #define __EPI_FILESYSTEM_H__ 21 22 #include "arrays.h" 23 #include "timestamp.h" 24 25 namespace epi 26 { 27 28 // Forward declarations 29 class file_c; 30 31 // A Filesystem directory entry 32 class filesys_direntry_c 33 { 34 public: 35 std::string name; 36 unsigned int size; 37 bool is_dir; 38 39 public: filesys_direntry_c()40 filesys_direntry_c() : name(), size(0), is_dir(false) 41 { } 42 ~filesys_direntry_c()43 ~filesys_direntry_c() 44 { } 45 }; 46 47 48 // A Filesystem directory 49 class filesystem_dir_c : public array_c 50 { 51 public: 52 filesystem_dir_c(); 53 ~filesystem_dir_c(); 54 55 private: 56 void CleanupObject(void *obj); 57 58 public: 59 bool AddEntry(filesys_direntry_c* fs_entry); 60 GetSize(void)61 int GetSize(void) { return array_entries; } 62 63 filesys_direntry_c *operator[](int idx); 64 }; 65 66 // ---- The Filesystem ---- 67 68 // Directory Functions 69 bool FS_GetCurrDir(char *dir, unsigned int bufsize); 70 bool FS_SetCurrDir(const char *dir); 71 72 bool FS_IsDir(const char *dir); 73 bool FS_MakeDir(const char *dir); 74 bool FS_RemoveDir(const char *dir); 75 76 bool FS_ReadDir(filesystem_dir_c *fsd, const char *dir, const char *mask); 77 78 // File Functions 79 bool FS_Access(const char *name, unsigned int flags); 80 file_c *FS_Open(const char *name, unsigned int flags); 81 82 // NOTE: there's no FS_Close() function, just delete the object. 83 84 bool FS_Copy(const char *src, const char *dest); 85 bool FS_Delete(const char *name); 86 bool FS_Rename(const char *oldname, const char *newname); 87 88 bool FS_GetModifiedTime(const char *filename, timestamp_c& t); 89 90 } // namespace epi 91 92 #endif /*__EPI_FILESYSTEM_H__*/ 93 94 //--- editor settings --- 95 // vi:ts=4:sw=4:noexpandtab 96