Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain/src/lib/util/filesys/file.h @ 9753

Last change on this file since 9753 was 9414, checked in by bensch, 18 years ago

merged back here the terrain.old

File size: 2.0 KB
RevLine 
[7609]1/*!
2 * @file file.h
3 * @brief Definition of File Handler class
4 */
5
6#ifndef __FILE_H_
7#define __FILE_H_
8
9
10#include <string>
[8333]11struct stat;
[7609]12
[7625]13//! A Class to Handle Files.
[7609]14class File
15{
16  public:
[7625]17  //! How the File should be opened.
[9414]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.
[7609]23  } OpenMode;
24public:
[7621]25  File();
[7609]26  File(const std::string& fileName);
27  File(const File& file);
[8148]28  virtual ~File();
[8332]29
30  /// Set-Up
[7621]31  void setFileName(const std::string& fileName);
32  File& operator=(const std::string& fileName);
33  File& operator=(const File& file);
[8332]34
35  /// Comparison
[7621]36  bool operator==(const std::string& fileName) const;
37  bool operator==(const File& file) const;
[7609]38
39  virtual bool open(OpenMode mode);
40  virtual bool close();
[9414]41  FILE* handle() const 
42  { return this->_handle; };
43  inline OpenMode mode() const
44  { return _mode; }
[7616]45  /** @returns the FileName of this File */
46  const std::string& name() const { return this->_name; };
47
[8332]48  /// Testing
[7620]49  bool exists() const;
50  bool isLink() const;
[8332]51  bool isFile() const;
[7620]52  bool isDirectory() const;
[8619]53  bool isReadable() const;
[7620]54  bool isWriteable() const;
55  bool isExecutable() const;
[7609]56
57
[8332]58  /// Operate on the FileSystem
[7609]59  bool copy(const File& destination);
60  bool rename(const File& destination);
61  bool touch();
62  bool remove();
63
[8332]64  /// Transformations
[7621]65  static void relToAbs(std::string& relFileName);
66  static void absToRel(std::string& absFileName);
[7611]67  static const std::string& cwd();
[7609]68
69  private:
[7616]70    void init();
[7621]71    void statFile();
[7609]72    void homeDirCheck(std::string& fileName);
73
74  private:
[9414]75    FILE*               _handle;          //!< The FileHandle (if set).
[7616]76    std::string         _name;            //!< The Name of the File.
77    stat*               _status;          //!< The Stat of the File.
[9414]78        OpenMode                        _mode;
[7611]79    static std::string  _cwd;             //!< The currend Working directory.
[7616]80
[7609]81};
82
[7611]83#endif /* __FILE_H_ */
Note: See TracBrowser for help on using the repository browser.