TCFile.h
Go to the documentation of this file.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
00033
00034
00035
00036 #ifndef _TC_FILE_H_
00037 #define _TC_FILE_H_
00038
00039 #include "TCSharedPtr.h"
00040
00041 #include <string>
00042 #include <vector>
00043
00044 namespace TC
00045 {
00061 namespace File
00062 {
00063 enum FileAttributes
00064 {
00065 FILEATTR_OWNER_WRITE = 0x00000001,
00066 FILEATTR_OWNER_READ = 0x00000002,
00067 FILEATTR_OWNER_EXEC = 0x00000004,
00068 FILEATTR_GROUP_WRITE = 0x00000008,
00069 FILEATTR_GROUP_READ = 0x00000010,
00070 FILEATTR_GROUP_EXEC = 0x00000020,
00071 FILEATTR_EVERYONE_WRITE = 0x00000040,
00072 FILEATTR_EVERYONE_READ = 0x00000080,
00073 FILEATTR_EVERYONE_EXEC = 0x00000100,
00074
00075 FILEATTR_READONLY = 0x00000200,
00076 FILEATTR_ARCHIVE = 0x00000400,
00077 FILEATTR_SYSTEM = 0x00000800,
00078 FILEATTR_HIDDEN = 0x00001000,
00079
00080 FILEATTR_WRITE = 0x00002000,
00081 FILEATTR_EXECUTE = 0x00004000
00082
00083 };
00084
00086 TCBASE_API bool Exists(const std::string &file);
00088 TCBASE_API bool IsFile(const std::string &file);
00090 TCBASE_API bool IsDirectory(const std::string &file);
00092 TCBASE_API bool IsReadable(const std::string &file);
00094 TCBASE_API bool IsWriteable(const std::string &file);
00096 TCBASE_API bool IsExecutable(const std::string &file);
00097
00099 TCBASE_API bool SetFileAttr(const std::string &file, uint32 attr);
00101 TCBASE_API uint64 GetFileSize(const std::string &file);
00102
00104 TCBASE_API sint64 GetModificationTime(const std::string &file);
00106 TCBASE_API sint64 GetLastAccessTime(const std::string &file);
00108 TCBASE_API sint64 GetCreationTime(const std::string &file);
00110 TCBASE_API sint64 GetTouchedTime(const std::string &file);
00111
00113 TCBASE_API std::string GetFileUser(const std::string &file);
00115 TCBASE_API std::string GetFileGroup(const std::string &file);
00116
00118 TCBASE_API bool ChangeDirectory(const std::string &directoryIn);
00120 TCBASE_API std::string GetDirectory();
00122 TCBASE_API std::vector<std::string> GetFileListOfDirectory(const std::string &searchDirectory,
00123 const std::string &searchExtension="");
00124 struct FileInfo
00125 {
00126 std::string name;
00127 sint64 last_modified;
00128 bool is_directory;
00129 };
00130 TCBASE_API void GetFileInfosOfDirectory(std::vector < FileInfo >& file_infos,
00131 const std::string & searchDirectory,
00132 const std::string& searchExtension="");
00133
00135 TCBASE_API bool Create(const std::string &file, bool removeOld=true);
00137 TCBASE_API bool Remove(const std::string &file);
00138
00139 class Progress
00140 {
00141 public:
00142 virtual void OnCurrentStatus(uint32 percent_done) = 0;
00143
00144 virtual ~Progress() {}
00145 };
00146
00148 TCBASE_API bool Copy(const std::string& source, const std::string& dest,
00149 SharedPtr<Progress> copy_status=SharedPtr<Progress>());
00151 TCBASE_API bool Move(const std::string& source, const std::string& dest);
00153 TCBASE_API bool CreateDirectory(const std::string &path);
00155 TCBASE_API bool CreateDirectoryRecursive(const std::string& path);
00156
00157 }
00158
00163 }
00164
00165 #endif // _TC_FILE_H_