00001 /* 00002 * $Id: BaseFile.h,v 1.6 2003/07/01 03:40:29 mindstorm2600 Exp $ 00003 * 00004 * juan v. guerrero <mindstorm2600@users.sourceforge.net> 00005 */ 00006 #ifndef __CLAW_FILE_H__ 00007 #define __CLAW_FILE_H__ 00008 #include<System.h> 00009 #include<String.h> 00010 00011 namespace clawsoft{ 00012 00018 class BaseFile:public System{ 00019 protected: 00021 int handler; 00023 String filename; 00025 int filemode; 00027 bool _opened; 00028 public: 00033 enum chmodBits{ 00035 SET_UID = 04000, 00037 SET_GID = 02000, 00039 STICKY = 01000, 00041 OWNER_READ = 00400, 00043 OWNER_WRITE = 00200, 00045 OWNER_EXEC = 00100, 00047 GROUP_READ = 00040, 00049 GROUP_WRITE = 00020, 00051 GROUP_EXEC = 00010, 00053 OTHER_READ = 00004, 00055 OTHER_WRITE = 00002, 00057 OTHER_EXEC = 00001 00058 }; 00063 enum OffsetStartingPoint{ 00065 FROM_THE_BEGINING, 00067 FROM_CURRENT_POSITION, 00069 FROM_THE_END 00070 }; 00075 enum FileOpenMode{ 00078 READ_ONLY, 00081 WRITE_ONLY, 00085 READ_WRITE, 00088 APPEND 00089 }; 00092 BaseFile(); 00095 BaseFile(const char *fname); 00096 BaseFile(const String &fname); 00097 virtual ~BaseFile(){ 00098 close(); 00099 } 00100 virtual void setFilename(const char *fname); 00101 virtual void setFilename(const String &fname); 00104 virtual void open(FileOpenMode mode); 00107 virtual void open(const char *fname, FileOpenMode mode); 00110 virtual void open(const String &fname, FileOpenMode mode); 00114 virtual Uint32 getOffset(); 00118 virtual Uint32 setOffset(Uint32 off, OffsetStartingPoint from = BaseFile::FROM_THE_BEGINING); 00120 virtual void close(); 00123 virtual void flush(); 00127 Uint32 getSize(); 00129 int chmod(int perms); 00130 00132 virtual Uint32 write(const void *buffer, Uint32 size); 00134 virtual Uint32 write(const char *buffer); 00136 virtual Uint32 read(void *buffer, Uint32 size); 00138 bool isOpen(){ 00139 return _opened; 00140 } 00141 00142 const String &getFilename(); 00143 }; 00144 00145 }; 00146 00147 #endif
Authors:
Juan V. Guerrero
Jannette C. Mejia
Juan C. Guevara
Powered by: