diff options
author | chai <chaifix@163.com> | 2019-03-29 22:51:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 22:51:04 +0800 |
commit | c302f5ae5f9e30a28e487e8a764d9cc31546bbea (patch) | |
tree | 7f18bedeece950600336ea7ced7c52c468552c98 /source/modules/asura-utils/io/file_system.h | |
parent | 157530b8b6e11efc5573d5a0db8987a440197aa1 (diff) |
*rename
Diffstat (limited to 'source/modules/asura-utils/io/file_system.h')
-rw-r--r-- | source/modules/asura-utils/io/file_system.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/source/modules/asura-utils/io/file_system.h b/source/modules/asura-utils/io/file_system.h new file mode 100644 index 0000000..849cbb6 --- /dev/null +++ b/source/modules/asura-utils/io/file_system.h @@ -0,0 +1,112 @@ +#ifndef __ASURA_ENGINE_FILESYSTEM_H__ +#define __ASURA_ENGINE_FILESYSTEM_H__ + +#include <map> +#include <string> + +#include "../scripting/portable.hpp" +#include "../singleton.hpp" +#include "../type.h" + +#include "file_data.h" +#include "file.h" + +namespace AsuraEngine +{ + namespace IO + { + + 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µġFilesystemʱͱ༭õ࣬AssetDatabaseԴ࣬framework + /// ʵ֣дFilesystemʵ֣AssetDatabaseṩļݴӦԴķ + /// + class Filesystem ASURA_FINAL + : public Singleton<Filesystem> + , public AEScripting::Portable<Filesystem> + { + public: + + LUAX_DECL_SINGLETON(Filesystem); + + ~Filesystem(); + + 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 mInited; ///< Ƿʼɹ + std::string mCwd; ///< ǰִļĹĿ¼ + MountDataMap mMountData; ///< ·ѹĵӳ + + 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 AEIO = AsuraEngine::IO; + +#endif
\ No newline at end of file |