Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/qt_gui/src/lib/util/file.h @ 7622

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

orxonox/qt_gui: all functions implemented so far

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