Changeset 9414 in orxonox.OLD for branches/terrain/src/lib/util/filesys
- Timestamp:
- Jul 24, 2006, 12:47:07 PM (18 years ago)
- Location:
- branches/terrain/src/lib/util/filesys
- Files:
-
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/util/filesys/file.cc
r8619 r9414 155 155 } 156 156 157 bool File::open(OpenMode mode) 158 { 159 #warning implement 160 return false; 157 bool File::open( OpenMode mode ) 158 { 159 static const char* openModeStrings[] = { 160 "r", "w", "r+", "a+" }; 161 _mode = mode; 162 _handle = fopen( name().c_str(), openModeStrings[mode] ); 163 return ( _handle != NULL ); 161 164 } 162 165 163 166 bool File::close() 164 167 { 165 #warning implement 166 return false; 168 if ( _handle != NULL ) { 169 int success = fclose( _handle ); 170 _handle = NULL; 171 return ( success == 0 ); 172 } 173 return false; 167 174 } 168 175 -
branches/terrain/src/lib/util/filesys/file.h
r8619 r9414 16 16 public: 17 17 //! How the File should be opened. 18 typedef enum 19 { 20 ReadOnly, //!< ReadOnly mode 21 WriteOnly, //!< WriteOnly mode 22 ReadWrite, //!< Read and Write mode together 23 Append, //!< Append at the end. 18 typedef enum { 19 ReadOnly = 0, //!< ReadOnly mode 20 WriteOnly = 1, //!< WriteOnly mode 21 ReadWrite = 2, //!< Read and Write mode together 22 Append = 3 //!< Append at the end. 24 23 } OpenMode; 25 26 24 public: 27 25 File(); … … 41 39 virtual bool open(OpenMode mode); 42 40 virtual bool close(); 43 int handle() const { return this->_handle; }; 44 41 FILE* handle() const 42 { return this->_handle; }; 43 inline OpenMode mode() const 44 { return _mode; } 45 45 /** @returns the FileName of this File */ 46 46 const std::string& name() const { return this->_name; }; … … 73 73 74 74 private: 75 int_handle; //!< The FileHandle (if set).75 FILE* _handle; //!< The FileHandle (if set). 76 76 std::string _name; //!< The Name of the File. 77 77 stat* _status; //!< The Stat of the File. 78 78 OpenMode _mode; 79 79 static std::string _cwd; //!< The currend Working directory. 80 80
Note: See TracChangeset
for help on using the changeset viewer.