diff options
Diffstat (limited to 'Source/modules/asura-base/FileSystem/FileManager.h')
-rw-r--r-- | Source/modules/asura-base/FileSystem/FileManager.h | 142 |
1 files changed, 70 insertions, 72 deletions
diff --git a/Source/modules/asura-base/FileSystem/FileManager.h b/Source/modules/asura-base/FileSystem/FileManager.h index ac97da3..2820321 100644 --- a/Source/modules/asura-base/FileSystem/FileManager.h +++ b/Source/modules/asura-base/FileSystem/FileManager.h @@ -11,101 +11,99 @@ #include "FileData.h" #include "File.h" -namespace AsuraEngine -{ - namespace FileSystem - { - - enum FileType - { - FILE_TYPE_FILE, ///< ļ - FILE_TYPE_DIRECTORY, ///< ļ - FILE_TYPE_SYMLINK, ///< - FILE_TYPE_OTHER, ///< - }; +namespace_begin(AsuraEngine) +namespace_begin(FileSystem) - struct FileInfo - { - int64 size; - int64 modtime; - FileType type; - }; +enum FileType +{ + FILE_TYPE_FILE, ///< ļ + FILE_TYPE_DIRECTORY, ///< ļ + FILE_TYPE_SYMLINK, ///< + FILE_TYPE_OTHER, ///< +}; - /// - /// Դء洢ԴָĿ¼ȡ۱༭ʱҪƷʵĻƣûIJϷĿ¼ - /// £file systemµġFileManagerʱͱ༭õ࣬AssetDatabaseԴ࣬framework - /// ʵ֣дFileManagerʵ֣AssetDatabaseṩļݴӦԴķ - /// - class FileManager ASURA_FINAL - : public Singleton<FileManager> - , public AEScripting::Portable<FileManager> - { - public: +struct FileInfo +{ + int64 size; + int64 modtime; + FileType type; +}; + +/// +/// Դء洢ԴָĿ¼ȡ۱༭ʱҪƷʵĻƣûIJϷĿ¼ +/// £file systemµġFileManagerʱͱ༭õ࣬AssetDatabaseԴ࣬framework +/// ʵ֣дFileManagerʵ֣AssetDatabaseṩļݴӦԴķ +/// +class FileManager ASURA_FINAL + : public Singleton<FileManager> + , public AEScripting::Portable<FileManager> +{ +public: - LUAX_DECL_SINGLETON(FileManager); + LUAX_DECL_SINGLETON(FileManager); - ~FileManager(); + ~FileManager(); - void Init(const char* arg0); + void Init(const char* arg0); - /// - /// ǰִļļ - /// - std::string GetWorkingDirectory(); + /// + /// ǰִļļ + /// + std::string GetWorkingDirectory(); - bool Mount(const std::string& locpath, const std::string& montpoint = "/", bool prepend = false); - bool Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint = "/", bool prepend = false); + bool Mount(const std::string& locpath, const std::string& montpoint = "/", bool prepend = false); + bool Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint = "/", bool prepend = false); - bool Unmount(const std::string& locpath); - bool Unmount(DataBuffer* db); + bool Unmount(const std::string& locpath); + bool Unmount(DataBuffer* db); - bool GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint); + bool GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint); - void SetWriteDirectory(const std::string locpath); - std::string GetWriteDirectory(); - File* NewFile(const std::string& name); - bool NewDirectory(const std::string& path); - bool Write(const std::string& path, ASURA_REF DataBuffer* buffer); - bool Append(const std::string& path, ASURA_REF DataBuffer* buffer); - bool Remove(const std::string& path); + void SetWriteDirectory(const std::string locpath); + std::string GetWriteDirectory(); + File* NewFile(const std::string& name); + bool NewDirectory(const std::string& path); + bool Write(const std::string& path, ASURA_REF DataBuffer* buffer); + bool Append(const std::string& path, ASURA_REF DataBuffer* buffer); + bool Remove(const std::string& path); - FileData* Read(const std::string& path); - bool GetFileInfo(const std::string& path, ASURA_OUT FileInfo* info); + FileData* Read(const std::string& path); + bool GetFileInfo(const std::string& path, ASURA_OUT FileInfo* info); - bool GetDirectoryItems(const std::string& path, ASURA_OUT std::vector<std::string>& items) { return false; }; + bool GetDirectoryItems(const std::string& path, ASURA_OUT std::vector<std::string>& items) { return false; }; - private: +private: - typedef std::map<std::string, DataBuffer*> MountDataMap; + typedef std::map<std::string, DataBuffer*> MountDataMap; - bool m_Inited; ///< Ƿʼɹ - std::string m_Cwd; ///< ǰִļĹĿ¼ - MountDataMap m_MountData; ///< ·ѹĵӳ + bool m_Inited; ///< Ƿʼɹ + std::string m_Cwd; ///< ǰִļĹĿ¼ + MountDataMap m_MountData; ///< ·ѹĵӳ - LUAX_DECL_METHOD(_Init); - LUAX_DECL_METHOD(_Mount); - LUAX_DECL_METHOD(_Unmount); - LUAX_DECL_METHOD(_GetMountPoint); + LUAX_DECL_METHOD(_Init); + LUAX_DECL_METHOD(_Mount); + LUAX_DECL_METHOD(_Unmount); + LUAX_DECL_METHOD(_GetMountPoint); - LUAX_DECL_METHOD(_SetWriteDirectory); - LUAX_DECL_METHOD(_GetWriteDirectory); - LUAX_DECL_METHOD(_CreateFile); - LUAX_DECL_METHOD(_CreateDirectory); + LUAX_DECL_METHOD(_SetWriteDirectory); + LUAX_DECL_METHOD(_GetWriteDirectory); + LUAX_DECL_METHOD(_CreateFile); + LUAX_DECL_METHOD(_CreateDirectory); - LUAX_DECL_METHOD(_Write); - LUAX_DECL_METHOD(_Append); - LUAX_DECL_METHOD(_Remove); + LUAX_DECL_METHOD(_Write); + LUAX_DECL_METHOD(_Append); + LUAX_DECL_METHOD(_Remove); - LUAX_DECL_METHOD(_Read); + LUAX_DECL_METHOD(_Read); - LUAX_DECL_METHOD(_GetFileInfo); + LUAX_DECL_METHOD(_GetFileInfo); - LUAX_DECL_METHOD(_GetDirectoryItems); + LUAX_DECL_METHOD(_GetDirectoryItems); - }; +}; - } -} +namespace_end +namespace_end namespace AEFileSystem = AsuraEngine::FileSystem; |