From 6a065c913e9308cc72e1ad0723b6167048f439b6 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 8 Aug 2019 08:56:51 +0800 Subject: *misc --- Source/modules/asura-base/FileSystem/FileManager.h | 142 ++++++++++----------- 1 file changed, 70 insertions(+), 72 deletions(-) (limited to 'Source/modules/asura-base/FileSystem/FileManager.h') 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, ///< 其他 +}; - /// - /// 资源管理,负责加载、存储资源,指定根目录等。无论编辑器还是运行时,都需要限制访问的机制,将用户的操作限制在游戏目录 - /// 下,file system就是做这件事的。FileManager是运行时和编辑器共用的类,AssetDatabase是用来管理资源的类,在framework - /// 里实现,单纯是逻辑处理,读写还是用FileManager实现,AssetDatabase提供根据文件内容创建对应资源的方法。 - /// - class FileManager ASURA_FINAL - : public Singleton - , public AEScripting::Portable - { - public: +struct FileInfo +{ + int64 size; + int64 modtime; + FileType type; +}; + +/// +/// 资源管理,负责加载、存储资源,指定根目录等。无论编辑器还是运行时,都需要限制访问的机制,将用户的操作限制在游戏目录 +/// 下,file system就是做这件事的。FileManager是运行时和编辑器共用的类,AssetDatabase是用来管理资源的类,在framework +/// 里实现,单纯是逻辑处理,读写还是用FileManager实现,AssetDatabase提供根据文件内容创建对应资源的方法。 +/// +class FileManager ASURA_FINAL + : public Singleton + , public AEScripting::Portable +{ +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& items) { return false; }; + bool GetDirectoryItems(const std::string& path, ASURA_OUT std::vector& items) { return false; }; - private: +private: - typedef std::map MountDataMap; + typedef std::map 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; -- cgit v1.1-26-g67d0