file.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef ZORBA_FILE_API_H
17 #define ZORBA_FILE_API_H
18 
19 #include <string>
20 
21 #include <zorba/config.h>
22 #include <zorba/api_shared_types.h>
23 
24 namespace zorba {
25 
26  /** \brief This class is the representation of file system file.
27  *
28  * ...
29  */
30  class ZORBA_DLL_PUBLIC DirectoryIterator : public SmartObject
31  {
32  public:
33 
34  virtual ~DirectoryIterator() {}
35 
36  virtual bool next(std::string& aPathStr) const = 0;
37  /** \brief Rewind the file find iterator
38  */
39  virtual void reset() = 0;
40  };
41 
42 
43  /** \brief This class is the representation of file system file.
44  *
45  * ...
46  */
47  class ZORBA_DLL_PUBLIC File : public SmartObject
48  {
49  public: // constructors
50 
51  virtual ~File() {}
52 
53  static File_t createFile(const std::string& path);
54 
55  static const char* getDirectorySeparator();
56 
57  static const char* getPathSeparator();
58 
59  public: // type, enums
60 
61 #ifdef WIN32
62  typedef __int64 FileSize_t;
63 #else
64  typedef int64_t FileSize_t;
65 #endif
66 
67 
68  public: // public methods
69 
70  virtual const std::string getFilePath() const = 0;
71  virtual const std::string getFileUri() const = 0;
72 
73  virtual bool isDirectory( bool follow_symlinks = true ) const = 0;
74  virtual bool isFile( bool follow_symlinks = true ) const = 0;
75  virtual bool isLink() const = 0;
76  virtual bool isVolume( bool follow_symlinks = true ) const = 0;
77  virtual bool isInvalid() const = 0; // deprecated
78  virtual bool exists( bool follow_symlinks = true ) const = 0;
79 
80  virtual void remove() = 0;
81  virtual bool create() = 0;
82  virtual bool rename(std::string const& newpath) = 0;
83 
84  virtual FileSize_t getSize() const = 0;
85 
86  virtual void mkdir(bool recursive) = 0;
87 
88  virtual DirectoryIterator_t files() const = 0;
89 
90  virtual void openInputStream(std::ifstream& aInStream, bool binary, bool trimByteOrderMark) const = 0;
91  virtual void openOutputStream(std::ofstream& aOutStream, bool binary, bool append) const = 0;
92 
93  virtual time_t lastModified() const = 0;
94 
95  };
96 
97 } /* namespace zorba */
98 
99 #endif
100 /* vim:set et sw=2 ts=2: */