File.h
Go to the documentation of this file.
00001 //
00002 // File.h
00003 //
00004 // $Id: //poco/1.3/Foundation/include/Poco/File.h#7 $
00005 //
00006 // Library: Foundation
00007 // Package: Filesystem
00008 // Module:  File
00009 //
00010 // Definition of the File class.
00011 //
00012 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00013 // and Contributors.
00014 //
00015 // Permission is hereby granted, free of charge, to any person or organization
00016 // obtaining a copy of the software and accompanying documentation covered by
00017 // this license (the "Software") to use, reproduce, display, distribute,
00018 // execute, and transmit the Software, and to prepare derivative works of the
00019 // Software, and to permit third-parties to whom the Software is furnished to
00020 // do so, all subject to the following:
00021 // 
00022 // The copyright notices in the Software and this entire statement, including
00023 // the above license grant, this restriction and the following disclaimer,
00024 // must be included in all copies of the Software, in whole or in part, and
00025 // all derivative works of the Software, unless such copies or derivative
00026 // works are solely in the form of machine-executable object code generated by
00027 // a source language processor.
00028 // 
00029 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00030 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00031 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00032 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00033 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00034 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00035 // DEALINGS IN THE SOFTWARE.
00036 //
00037 
00038 
00039 #ifndef Foundation_File_INCLUDED
00040 #define Foundation_File_INCLUDED
00041 
00042 
00043 #include "Poco/Foundation.h"
00044 #include "Poco/Timestamp.h"
00045 #include <vector>
00046 
00047 
00048 #if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
00049 #include "Poco/File_WIN32U.h"
00050 #elif defined(POCO_OS_FAMILY_WINDOWS)
00051 #include "Poco/File_WIN32.h"
00052 #elif defined(POCO_OS_FAMILY_UNIX)
00053 #include "Poco/File_UNIX.h"
00054 #else
00055 #include "Poco/File_VMS.h"
00056 #endif
00057 
00058 
00059 namespace Poco {
00060 
00061 
00062 class Path;
00063 
00064 
00065 class Foundation_API File: private FileImpl
00067 {
00068 public:
00069         typedef FileSizeImpl FileSize;
00070 
00071         File();
00073 
00074         File(const std::string& path);
00076                 
00077         File(const char* path);
00079 
00080         File(const Path& path);
00082                 
00083         File(const File& file);
00085 
00086         virtual ~File();
00088         
00089         File& operator = (const File& file);
00091 
00092         File& operator = (const std::string& path);
00094 
00095         File& operator = (const char* path);
00097 
00098         File& operator = (const Path& path);
00100                 
00101         void swap(File& file);
00103 
00104         const std::string& path() const;
00106         
00107         bool exists() const;
00109                 
00110         bool canRead() const;
00112                 
00113         bool canWrite() const;
00115 
00116         bool canExecute() const;
00123 
00124         bool isFile() const;
00126                 
00127         bool isLink() const;
00129                 
00130         bool isDirectory() const;
00132                 
00133         bool isDevice() const;
00135 
00136         bool isHidden() const;
00144 
00145         Timestamp created() const;
00153 
00154         Timestamp getLastModified() const;
00156                 
00157         void setLastModified(const Timestamp& ts);
00159                 
00160         FileSize getSize() const;
00162                 
00163         void setSize(FileSize size);
00166                 
00167         void setWriteable(bool flag = true);
00171                 
00172         void setReadOnly(bool flag = true);
00176                 
00177         void setExecutable(bool flag = true);
00183                 
00184         void copyTo(const std::string& path) const;
00189 
00190         void moveTo(const std::string& path);
00193                 
00194         void renameTo(const std::string& path);
00196                 
00197         void remove(bool recursive = false);
00201         
00202         bool createFile();
00207         
00208         bool createDirectory();
00212         
00213         void createDirectories();
00216                 
00217         void list(std::vector<std::string>& files) const;
00220 
00221         void list(std::vector<File>& files) const;
00224 
00225         bool operator == (const File& file) const;
00226         bool operator != (const File& file) const;
00227         bool operator <  (const File& file) const;
00228         bool operator <= (const File& file) const;
00229         bool operator >  (const File& file) const;
00230         bool operator >= (const File& file) const;
00231         
00232         static void handleLastError(const std::string& path);
00235 
00236 protected:
00237         void copyDirectory(const std::string& path) const;
00239 };
00240 
00241 
00242 //
00243 // inlines
00244 //
00245 inline const std::string& File::path() const
00246 {
00247         return getPathImpl();
00248 }
00249 
00250 
00251 inline bool File::operator == (const File& file) const
00252 {
00253         return getPathImpl() == file.getPathImpl();
00254 }
00255 
00256 
00257 inline bool File::operator != (const File& file) const
00258 {
00259         return getPathImpl() != file.getPathImpl();
00260 }
00261 
00262 
00263 inline bool File::operator < (const File& file) const
00264 {
00265         return getPathImpl() < file.getPathImpl();
00266 }
00267 
00268 
00269 inline bool File::operator <= (const File& file) const
00270 {
00271         return getPathImpl() <= file.getPathImpl();
00272 }
00273 
00274 
00275 inline bool File::operator > (const File& file) const
00276 {
00277         return getPathImpl() > file.getPathImpl();
00278 }
00279 
00280 
00281 inline bool File::operator >= (const File& file) const
00282 {
00283         return getPathImpl() >= file.getPathImpl();
00284 }
00285 
00286 
00287 inline void swap(File& f1, File& f2)
00288 {
00289         f1.swap(f2);
00290 }
00291 
00292 
00293 } // namespace Poco
00294 
00295 
00296 #endif // Foundation_File_INCLUDED


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19