Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9414 in orxonox.OLD for branches/terrain/src/lib/util/filesys


Ignore:
Timestamp:
Jul 24, 2006, 12:47:07 PM (18 years ago)
Author:
bensch
Message:

merged back here the terrain.old

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  
    155155}
    156156
    157 bool File::open(OpenMode mode)
    158 {
    159 #warning implement
    160   return false;
     157bool 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 );
    161164}
    162165
    163166bool File::close()
    164167{
    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;
    167174}
    168175
  • branches/terrain/src/lib/util/filesys/file.h

    r8619 r9414  
    1616  public:
    1717  //! 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.
    2423  } OpenMode;
    25 
    2624public:
    2725  File();
     
    4139  virtual bool open(OpenMode mode);
    4240  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; }
    4545  /** @returns the FileName of this File */
    4646  const std::string& name() const { return this->_name; };
     
    7373
    7474  private:
    75     int                 _handle;          //!< The FileHandle (if set).
     75    FILE*               _handle;          //!< The FileHandle (if set).
    7676    std::string         _name;            //!< The Name of the File.
    7777    stat*               _status;          //!< The Stat of the File.
    78 
     78        OpenMode                        _mode;
    7979    static std::string  _cwd;             //!< The currend Working directory.
    8080
Note: See TracChangeset for help on using the changeset viewer.