Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/filesys/file.h @ 9442

Last change on this file since 9442 was 8619, checked in by bensch, 18 years ago

trunk: merged the gui-branche back.
merged with command:
svn merge -r8520:HEAD https://svn.orxonox.net/orxonox/branches/gui
no conflicts

File size: 1.9 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.
[7609]18  typedef enum
19  {
[7625]20    ReadOnly,      //!< ReadOnly mode
21    WriteOnly,     //!< WriteOnly mode
22    ReadWrite,     //!< Read and Write mode together
23    Append,        //!< Append at the end.
[7609]24  } OpenMode;
25
26public:
[7621]27  File();
[7609]28  File(const std::string& fileName);
29  File(const File& file);
[8148]30  virtual ~File();
[8332]31
32  /// Set-Up
[7621]33  void setFileName(const std::string& fileName);
34  File& operator=(const std::string& fileName);
35  File& operator=(const File& file);
[8332]36
37  /// Comparison
[7621]38  bool operator==(const std::string& fileName) const;
39  bool operator==(const File& file) const;
[7609]40
41  virtual bool open(OpenMode mode);
42  virtual bool close();
[7621]43  int handle() const { return this->_handle; };
[7609]44
[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:
[7611]75    int                 _handle;          //!< The FileHandle (if set).
[7616]76    std::string         _name;            //!< The Name of the File.
77    stat*               _status;          //!< The Stat of the File.
[7611]78
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.