summaryrefslogtreecommitdiff
path: root/source/modules/asura-utils/IO/FileSystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/modules/asura-utils/IO/FileSystem.h')
-rw-r--r--source/modules/asura-utils/IO/FileSystem.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/source/modules/asura-utils/IO/FileSystem.h b/source/modules/asura-utils/IO/FileSystem.h
new file mode 100644
index 0000000..f0ac6ba
--- /dev/null
+++ b/source/modules/asura-utils/IO/FileSystem.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 "FileData.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 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 AEIO = AsuraEngine::IO;
+
+#endif \ No newline at end of file