Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: nicer File-Class, that can reopen files.

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
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.