Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/util/file.h @ 8290

Last change on this file since 8290 was 8148, checked in by bensch, 19 years ago

trunk: output of EventListener Nicer

File size: 1.8 KB
Line 
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>
11typedef struct stat;
12
13//! A Class to Handle Files.
14class File
15{
16  public:
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.
24  } OpenMode;
25
26public:
27  File();
28  File(const std::string& fileName);
29  File(const File& file);
30  virtual ~File();
31  void setFileName(const std::string& fileName);
32  File& operator=(const std::string& fileName);
33  File& operator=(const File& file);
34  bool operator==(const std::string& fileName) const;
35  bool operator==(const File& file) const;
36
37  virtual bool open(OpenMode mode);
38  virtual bool close();
39  int handle() const { return this->_handle; };
40
41  /** @returns the FileName of this File */
42  const std::string& name() const { return this->_name; };
43
44  bool exists() const;
45  bool isLink() const;
46  bool isFile() const ;
47  bool isDirectory() const;
48  bool isReadeable() const;
49  bool isWriteable() const;
50  bool isExecutable() const;
51
52
53  bool copy(const File& destination);
54  bool rename(const File& destination);
55  bool touch();
56  bool remove();
57
58  static void relToAbs(std::string& relFileName);
59  static void absToRel(std::string& absFileName);
60  static const std::string& cwd();
61
62  private:
63    void init();
64    void statFile();
65    void homeDirCheck(std::string& fileName);
66
67  private:
68    int                 _handle;          //!< The FileHandle (if set).
69    std::string         _name;            //!< The Name of the File.
70    stat*               _status;          //!< The Stat of the File.
71
72    static std::string  _cwd;             //!< The currend Working directory.
73
74};
75
76#endif /* __FILE_H_ */
Note: See TracBrowser for help on using the repository browser.