00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00036 #ifndef OW_FILESYSTEM_HPP_INCLUDE_GUARD_
00037 #define OW_FILESYSTEM_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_Types.hpp"
00040 #include "OW_ArrayFwd.hpp"
00041 #include "OW_Exception.hpp"
00042 #include "OW_CommonFwd.hpp"
00043 
00044 #ifdef OW_HAVE_SYS_PARAM_H
00045 #include <sys/param.h>
00046 #endif
00047 #ifndef MAXPATHLEN
00048 #ifdef PATH_MAX
00049 #define MAXPATHLEN PATH_MAX
00050 #else
00051 #define MAXPATHLEN 1024
00052 #endif
00053 #endif
00054 
00055 namespace OW_NAMESPACE
00056 {
00057 
00058 OW_DECLARE_APIEXCEPTION(FileSystem, OW_COMMON_API)
00059 
00060 
00064 namespace FileSystem
00065 {
00070    OW_COMMON_API File openFile(const String& path);
00078    OW_COMMON_API File createFile(const String& path);
00085    OW_COMMON_API File openOrCreateFile(const String& path);
00092    OW_COMMON_API int changeFileOwner(const String& filename,
00093       const UserId& userId);
00097    OW_COMMON_API bool exists(const String& path);
00098 #ifndef OW_WIN32
00099 
00107    OW_COMMON_API bool isExecutable(const String& path);
00108 #endif
00109 
00112    OW_COMMON_API bool canRead(const String& path);
00116    OW_COMMON_API bool canWrite(const String& path);
00117 #ifndef OW_WIN32
00118 
00126    OW_COMMON_API bool isLink(const String& path);
00127 #endif
00128 
00131    OW_COMMON_API bool isDirectory(const String& path);
00137    OW_COMMON_API bool changeDirectory(const String& path);
00144    OW_COMMON_API bool makeDirectory(const String& path, int mode=0777);
00151    OW_COMMON_API bool getFileSize(const String& path, off_t& size);
00157    OW_COMMON_API bool removeDirectory(const String& path);
00163    OW_COMMON_API bool removeFile(const String& path);
00170    OW_COMMON_API bool getDirectoryContents(const String& path,
00171       StringArray& dirEntries);
00178    OW_COMMON_API bool renameFile(const String& oldFileName,
00179       const String& newFileName);
00191    OW_COMMON_API size_t read(const FileHandle& hdl, void* bfr, size_t numberOfBytes,
00192       off_t offset=-1L);
00203    OW_COMMON_API size_t write(FileHandle& hdl, const void* bfr,
00204       size_t numberOfBytes, off_t offset=-1L);
00216    OW_COMMON_API off_t seek(const FileHandle& hdl, off_t offset, int whence);
00222    OW_COMMON_API off_t tell(const FileHandle& hdl);
00228    OW_COMMON_API void rewind(const FileHandle& hdl);
00234    OW_COMMON_API int close(const FileHandle& hdl);
00239    OW_COMMON_API int flush(FileHandle& hdl);
00245    OW_COMMON_API void initRandomFile(const String& file) OW_DEPRECATED;
00253    OW_COMMON_API String getFileContents(const String& filename);
00254    
00262    OW_COMMON_API StringArray getFileLines(const String& filename);
00263 
00270    OW_COMMON_API String readSymbolicLink(const String& path);
00271 
00272    namespace Path
00273    {
00284       OW_COMMON_API String realPath(const String& path);
00285 
00296       OW_COMMON_API String dirname(const String& filename);
00297 
00304       OW_COMMON_API String getCurrentWorkingDirectory();
00305 
00306 
00307    } 
00308 
00309 } 
00310 
00311 } 
00312 
00313 #endif