file.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2008 The FLWOR Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef ZORBA_FILE_API_H
00017 #define ZORBA_FILE_API_H
00018 
00019 #include <string>
00020 
00021 #include <zorba/config.h>
00022 #include <zorba/api_shared_types.h>
00023 
00024 namespace zorba {
00025 
00026   /** \brief This class is the representation of file system file.
00027    *
00028    * ...
00029    */
00030   class ZORBA_DLL_PUBLIC DirectoryIterator : public SmartObject
00031   {
00032     public:
00033 
00034       virtual ~DirectoryIterator() {}
00035 
00036       virtual bool next(std::string& aPathStr) const = 0;
00037       /** \brief Rewind the file find iterator
00038       */
00039       virtual void reset() = 0;
00040   };
00041 
00042 
00043   /** \brief This class is the representation of file system file.
00044    *
00045    * ...
00046    */
00047   class ZORBA_DLL_PUBLIC File : public SmartObject
00048   {
00049     public: // constructors
00050 
00051       virtual ~File() {}
00052 
00053       static File_t createFile(const std::string& path);
00054 
00055       static const char* getDirectorySeparator();
00056 
00057       static const char* getPathSeparator();
00058 
00059     public: // type, enums
00060 
00061 #ifdef WIN32
00062       typedef __int64 FileSize_t;
00063 #else
00064       typedef int64_t FileSize_t;
00065 #endif
00066 
00067 
00068     public: // public methods
00069 
00070       virtual const std::string getFilePath() const = 0;
00071       virtual const std::string getFileUri() const = 0;
00072 
00073       virtual bool isDirectory() const = 0;
00074       virtual bool isFile() const = 0;
00075       virtual bool isLink() const = 0;
00076       virtual bool isVolume() const = 0;
00077       virtual bool isInvalid() const = 0;
00078       virtual bool exists() const = 0;
00079 
00080       virtual void remove() = 0;
00081       virtual bool create() = 0;
00082       virtual bool rename(std::string const& newpath) = 0;
00083 
00084       virtual FileSize_t getSize() const = 0;
00085 
00086       virtual void mkdir(bool recursive) = 0;
00087 
00088       virtual DirectoryIterator_t files() const = 0;
00089 
00090       virtual void openInputStream(std::ifstream& aInStream, bool binary, bool trimByteOrderMark) const = 0;
00091       virtual void openOutputStream(std::ofstream& aOutStream, bool binary, bool append) const = 0;
00092 
00093       virtual time_t lastModified() const = 0;
00094 
00095   };
00096 
00097 } /* namespace zorba */
00098 
00099 #endif
00100 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus