Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7923 was 7661, checked in by bensch, 19 years ago

orxonox/trunk: merged the QT_GUI back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/qt_gui . -r7607:HEAD

absolutely no conflicts :)

File size: 1.8 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>
[7616]11typedef struct 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);
30  ~File();
[7621]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;
[7609]36
37  virtual bool open(OpenMode mode);
38  virtual bool close();
[7621]39  int handle() const { return this->_handle; };
[7609]40
[7616]41  /** @returns the FileName of this File */
42  const std::string& name() const { return this->_name; };
43
[7620]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;
[7609]51
52
53  bool copy(const File& destination);
54  bool rename(const File& destination);
55  bool touch();
56  bool remove();
57
[7621]58  static void relToAbs(std::string& relFileName);
59  static void absToRel(std::string& absFileName);
[7611]60  static const std::string& cwd();
[7609]61
62  private:
[7616]63    void init();
[7621]64    void statFile();
[7609]65    void homeDirCheck(std::string& fileName);
66
67  private:
[7611]68    int                 _handle;          //!< The FileHandle (if set).
[7616]69    std::string         _name;            //!< The Name of the File.
70    stat*               _status;          //!< The Stat of the File.
[7611]71
72    static std::string  _cwd;             //!< The currend Working directory.
[7616]73
[7609]74};
75
[7611]76#endif /* __FILE_H_ */
Note: See TracBrowser for help on using the repository browser.