diff options
author | chai <chaifix@163.com> | 2019-08-07 21:08:47 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-07 21:08:47 +0800 |
commit | 0c391fdbce5a079cf03e483eb6174dd47806163d (patch) | |
tree | b06cd7a9d0ae0d9bb9e82f3dcb786dfce11f8628 /Source/modules/asura-base/FileSystem/FileManager.h | |
parent | 9686368e58e25cbd6dc37d686bdd2be3f80486d6 (diff) |
*misc
Diffstat (limited to 'Source/modules/asura-base/FileSystem/FileManager.h')
-rw-r--r-- | Source/modules/asura-base/FileSystem/FileManager.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/Source/modules/asura-base/FileSystem/FileManager.h b/Source/modules/asura-base/FileSystem/FileManager.h new file mode 100644 index 0000000..ac97da3 --- /dev/null +++ b/Source/modules/asura-base/FileSystem/FileManager.h @@ -0,0 +1,112 @@ +#ifndef _ASURA_ENGINE_FILESYSTEM_H_ +#define _ASURA_ENGINE_FILESYSTEM_H_ + +#include <map> +#include <string> + +#include "../Scripting/Scripting.h" +#include "../Singleton.hpp" +#include "../Type.h" + +#include "FileData.h" +#include "File.h" + +namespace AsuraEngine +{ + namespace FileSystem + { + + enum FileType + { + FILE_TYPE_FILE, ///< ļ + FILE_TYPE_DIRECTORY, ///< ļ + FILE_TYPE_SYMLINK, ///< + FILE_TYPE_OTHER, ///< + }; + + 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); + + ~FileManager(); + + void Init(const char* arg0); + + /// + /// ǰִļļ + /// + 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 Unmount(const std::string& locpath); + bool Unmount(DataBuffer* db); + + 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); + + 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; }; + + private: + + typedef std::map<std::string, DataBuffer*> MountDataMap; + + 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(_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(_Read); + + LUAX_DECL_METHOD(_GetFileInfo); + + LUAX_DECL_METHOD(_GetDirectoryItems); + + }; + + } +} + +namespace AEFileSystem = AsuraEngine::FileSystem; + +#endif
\ No newline at end of file |