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
00031
00032
00038 #ifndef BLOCXX_FILESYSTEM_HPP_INCLUDE_GUARD_
00039 #define BLOCXX_FILESYSTEM_HPP_INCLUDE_GUARD_
00040 #include "blocxx/BLOCXX_config.h"
00041 #include "blocxx/Types.hpp"
00042 #include "blocxx/ArrayFwd.hpp"
00043 #include "blocxx/Exception.hpp"
00044 #include "blocxx/CommonFwd.hpp"
00045
00046 #ifdef BLOCXX_HAVE_SYS_PARAM_H
00047 #include <sys/param.h>
00048 #endif
00049 #ifndef MAXPATHLEN
00050 #ifdef PATH_MAX
00051 #define MAXPATHLEN PATH_MAX
00052 #else
00053 #define MAXPATHLEN 1024
00054 #endif
00055 #endif
00056
00057 namespace BLOCXX_NAMESPACE
00058 {
00059
00060 BLOCXX_DECLARE_APIEXCEPTION(FileSystem, BLOCXX_COMMON_API)
00061
00062
00066 namespace FileSystem
00067 {
00072 BLOCXX_COMMON_API File openFile(const String& path);
00080 BLOCXX_COMMON_API File createFile(const String& path);
00087 BLOCXX_COMMON_API File openOrCreateFile(const String& path);
00094 BLOCXX_COMMON_API int changeFileOwner(const String& filename,
00095 const UserId& userId);
00099 BLOCXX_COMMON_API bool exists(const String& path);
00100 #ifndef BLOCXX_WIN32
00101
00109 BLOCXX_COMMON_API bool isExecutable(const String& path);
00110 #endif
00111
00114 BLOCXX_COMMON_API bool canRead(const String& path);
00118 BLOCXX_COMMON_API bool canWrite(const String& path);
00119 #ifndef BLOCXX_WIN32
00120
00128 BLOCXX_COMMON_API bool isLink(const String& path);
00129 #endif
00130
00133 BLOCXX_COMMON_API bool isDirectory(const String& path);
00139 BLOCXX_COMMON_API bool changeDirectory(const String& path);
00146 BLOCXX_COMMON_API bool makeDirectory(const String& path, int mode=0777);
00153 BLOCXX_COMMON_API bool getFileSize(const String& path, off_t& size);
00159 BLOCXX_COMMON_API bool removeDirectory(const String& path);
00165 BLOCXX_COMMON_API bool removeFile(const String& path);
00172 BLOCXX_COMMON_API bool getDirectoryContents(const String& path,
00173 StringArray& dirEntries);
00180 BLOCXX_COMMON_API bool renameFile(const String& oldFileName,
00181 const String& newFileName);
00193 BLOCXX_COMMON_API size_t read(const FileHandle& hdl, void* bfr, size_t numberOfBytes,
00194 off_t offset=-1L);
00205 BLOCXX_COMMON_API size_t write(FileHandle& hdl, const void* bfr,
00206 size_t numberOfBytes, off_t offset=-1L);
00218 BLOCXX_COMMON_API off_t seek(const FileHandle& hdl, off_t offset, int whence);
00224 BLOCXX_COMMON_API off_t tell(const FileHandle& hdl);
00230 BLOCXX_COMMON_API void rewind(const FileHandle& hdl);
00236 BLOCXX_COMMON_API int close(const FileHandle& hdl);
00241 BLOCXX_COMMON_API int flush(FileHandle& hdl);
00249 BLOCXX_COMMON_API String getFileContents(const String& filename);
00250
00258 BLOCXX_COMMON_API StringArray getFileLines(const String& filename);
00259
00266 BLOCXX_COMMON_API String readSymbolicLink(const String& path);
00267
00268 namespace Path
00269 {
00280 BLOCXX_COMMON_API String realPath(const String& path);
00281
00292 BLOCXX_COMMON_API String dirname(const String& filename);
00293
00300 BLOCXX_COMMON_API String getCurrentWorkingDirectory();
00301
00302
00303 }
00304
00305 }
00306
00307 }
00308
00309 #endif