From bad78945ceba425f6a80e3b8dca2414d592970eb Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 2 Aug 2019 20:51:00 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=90=8D=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asura-utils/io/binding/_data_buffer.cpp | 2 +- .../modules/asura-utils/io/binding/_file_data.cpp | 2 +- .../asura-utils/io/binding/_file_system.cpp | 2 +- source/modules/asura-utils/io/binding/_io_task.cpp | 2 +- source/modules/asura-utils/io/compressor.cpp | 2 +- source/modules/asura-utils/io/compressor.h | 6 +- source/modules/asura-utils/io/data_buffer.cpp | 156 ---------------- source/modules/asura-utils/io/data_buffer.h | 87 --------- source/modules/asura-utils/io/decoded_data.h | 41 ----- source/modules/asura-utils/io/file.cpp | 4 +- source/modules/asura-utils/io/file.h | 10 +- source/modules/asura-utils/io/file_data.cpp | 59 ------ source/modules/asura-utils/io/file_data.h | 69 ------- source/modules/asura-utils/io/file_system.cpp | 198 --------------------- source/modules/asura-utils/io/file_system.h | 112 ------------ source/modules/asura-utils/io/io_batch_task.cpp | 0 source/modules/asura-utils/io/io_batch_task.h | 31 ---- source/modules/asura-utils/io/io_task.cpp | 61 ------- source/modules/asura-utils/io/io_task.h | 56 ------ source/modules/asura-utils/io/renewable.h | 2 +- 20 files changed, 16 insertions(+), 886 deletions(-) delete mode 100644 source/modules/asura-utils/io/data_buffer.cpp delete mode 100644 source/modules/asura-utils/io/data_buffer.h delete mode 100644 source/modules/asura-utils/io/decoded_data.h delete mode 100644 source/modules/asura-utils/io/file_data.cpp delete mode 100644 source/modules/asura-utils/io/file_data.h delete mode 100644 source/modules/asura-utils/io/file_system.cpp delete mode 100644 source/modules/asura-utils/io/file_system.h delete mode 100644 source/modules/asura-utils/io/io_batch_task.cpp delete mode 100644 source/modules/asura-utils/io/io_batch_task.h delete mode 100644 source/modules/asura-utils/io/io_task.cpp delete mode 100644 source/modules/asura-utils/io/io_task.h (limited to 'source/modules/asura-utils/io') diff --git a/source/modules/asura-utils/io/binding/_data_buffer.cpp b/source/modules/asura-utils/io/binding/_data_buffer.cpp index ac240e5..9d3f3a0 100644 --- a/source/modules/asura-utils/io/binding/_data_buffer.cpp +++ b/source/modules/asura-utils/io/binding/_data_buffer.cpp @@ -1,4 +1,4 @@ -#include "../data_buffer.h" +#include "../DataBuffer.h" using namespace Luax; diff --git a/source/modules/asura-utils/io/binding/_file_data.cpp b/source/modules/asura-utils/io/binding/_file_data.cpp index f4f6584..55cbc8b 100644 --- a/source/modules/asura-utils/io/binding/_file_data.cpp +++ b/source/modules/asura-utils/io/binding/_file_data.cpp @@ -1,4 +1,4 @@ -#include "../file_data.h" +#include "../FileData.h" using namespace std; diff --git a/source/modules/asura-utils/io/binding/_file_system.cpp b/source/modules/asura-utils/io/binding/_file_system.cpp index 0dc24d0..ace3c5f 100644 --- a/source/modules/asura-utils/io/binding/_file_system.cpp +++ b/source/modules/asura-utils/io/binding/_file_system.cpp @@ -1,4 +1,4 @@ -#include "../file_system.h" +#include "../FileSystem.h" using namespace Luax; diff --git a/source/modules/asura-utils/io/binding/_io_task.cpp b/source/modules/asura-utils/io/binding/_io_task.cpp index 4da8dc3..058f4fd 100644 --- a/source/modules/asura-utils/io/binding/_io_task.cpp +++ b/source/modules/asura-utils/io/binding/_io_task.cpp @@ -1,4 +1,4 @@ -#include "../io_task.h" +#include "../IOTask.h" using namespace std; diff --git a/source/modules/asura-utils/io/compressor.cpp b/source/modules/asura-utils/io/compressor.cpp index 095eff4..4202263 100644 --- a/source/modules/asura-utils/io/compressor.cpp +++ b/source/modules/asura-utils/io/compressor.cpp @@ -1,4 +1,4 @@ -#include "compressor.h" +#include "Compressor.h" namespace AsuraEngine { diff --git a/source/modules/asura-utils/io/compressor.h b/source/modules/asura-utils/io/compressor.h index 65fd88a..dc25e2a 100644 --- a/source/modules/asura-utils/io/compressor.h +++ b/source/modules/asura-utils/io/compressor.h @@ -1,7 +1,7 @@ -#ifndef __ASURA_COMPRESSOR_H__ -#define __ASURA_COMPRESSOR_H__ +#ifndef _ASURA_COMPRESSOR_H_ +#define _ASURA_COMPRESSOR_H_ -#include "../scripting/portable.hpp" +#include "../Scripting/Portable.hpp" namespace AsuraEngine { diff --git a/source/modules/asura-utils/io/data_buffer.cpp b/source/modules/asura-utils/io/data_buffer.cpp deleted file mode 100644 index 37f749c..0000000 --- a/source/modules/asura-utils/io/data_buffer.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include -#include "data_buffer.h" - -using namespace AEThreading; - -namespace AsuraEngine -{ - namespace IO - { - - DataBuffer::DataBuffer(DataBuffer& src) - : m_Size(0) - , m_Capacity(0) - , m_Bytes(nullptr) - { - // 初始化容量 - lock(m_Mutex) - { - m_Capacity = src.m_Size; - m_Bytes = new byte[m_Capacity]; - Clear(); - - Load(src); - } - } - - DataBuffer::DataBuffer(std::size_t capacity) - : m_Size(0) - , m_Capacity(0) - , m_Bytes(nullptr) - { - lock(m_Mutex) - { - m_Capacity = capacity; - m_Bytes = new byte[m_Capacity]; - Clear(); - } - } - - DataBuffer::DataBuffer(const void* data, std::size_t size) - : m_Capacity(0) - , m_Size(0) - , m_Bytes(nullptr) - { - lock(m_Mutex) - { - m_Capacity = size; - m_Bytes = new byte[m_Capacity]; - Clear(); - - Load(data, size); - } - } - - DataBuffer::~DataBuffer() - { - lock(m_Mutex) - { - delete[] m_Bytes; - } - } - - void DataBuffer::Refactor(size_t capacity) - { - lock(m_Mutex) - { - if (!m_Bytes || m_Capacity != capacity) - { - if(m_Bytes) - delete[] m_Bytes; - m_Capacity = capacity; - m_Bytes = new byte[m_Capacity]; - m_Size = 0; - } - Clear(); - } - } - - void DataBuffer::Load(DataBuffer& db) - { - lock(m_Mutex) - { - Load(db.GetData(), db.GetSize()); - } - } - - void DataBuffer::Load(const void* data, std::size_t size) - { - lock(m_Mutex) - { - ASSERT(m_Capacity >= size); - memcpy(m_Bytes, data, size); - m_Size = size; - } - } - - void DataBuffer::Move(void* bytes, std::size_t size) - { - lock(m_Mutex) - { - if (m_Bytes == bytes) - { - // 如果是自身,代表更新size值,在读文件时会这样 - m_Size = size; - } - else - { - if (m_Bytes) - delete[] m_Bytes; - m_Bytes = (byte*)bytes; - m_Size = size; - m_Capacity = size; - } - } - } - - byte* DataBuffer::GetData() - { - return m_Bytes; - } - - void DataBuffer::Clear() - { - lock(m_Mutex) - { - if (m_Bytes) - { - memset(m_Bytes, 0, m_Size); - m_Size = 0; - } - } - } - - std::size_t DataBuffer::GetSize() - { - return m_Size; - } - - std::size_t DataBuffer::GetCapacity() - { - return m_Capacity; - } - - void DataBuffer::Lock() - { - m_Mutex.Lock(); - } - - void DataBuffer::Unlock() - { - m_Mutex.Unlock(); - } - - } -} \ No newline at end of file diff --git a/source/modules/asura-utils/io/data_buffer.h b/source/modules/asura-utils/io/data_buffer.h deleted file mode 100644 index 53ed603..0000000 --- a/source/modules/asura-utils/io/data_buffer.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef __ASURA_ENGINE_DATABUFFER_H__ -#define __ASURA_ENGINE_DATABUFFER_H__ - -#include - -#include "../scripting/portable.hpp" -#include "../threading/mutex.h" - -namespace AsuraEngine -{ - namespace IO - { - - /// - /// 对内存数据的封装,所有的数据使用Data buffer包装,不直接使用const void*。通过resource manager读取。 - /// - class DataBuffer ASURA_FINAL - : public AEScripting::Portable - { - public: - - LUAX_DECL_FACTORY(DataBuffer); - - DataBuffer(DataBuffer& src); - DataBuffer(std::size_t capacity); - DataBuffer(const void* bytes, std::size_t size); - ~DataBuffer(); - - byte* GetData(); - size_t GetSize(); - size_t GetCapacity(); - - /// - /// 修改容量,并清空 - /// - void Refactor(size_t capacity); - - /// - /// 拷贝数据源到此缓冲 - /// - void Load(DataBuffer& db); - void Load(const void* bytes, std::size_t size); - - /// - /// 绑定bytes,并拥有所有权,capacity为size - /// - void Move(void* bytes, std::size_t size); - - /// - /// 清理缓冲 - /// - void Clear(); - - void Lock(); - void Unlock(); - - private: - - LUAX_DECL_METHOD(_New); - LUAX_DECL_METHOD(_GetData); - LUAX_DECL_METHOD(_GetSize); - LUAX_DECL_METHOD(_GetCapacity); - LUAX_DECL_METHOD(_Refactor); - LUAX_DECL_METHOD(_Load); - LUAX_DECL_METHOD(_Clear); - - /// - /// Buffer首地址和里面数据的长度 - /// - byte* m_Bytes; - size_t m_Size; - - /// - /// Buffer容量。 - /// - size_t m_Capacity; - - AEThreading::Mutex m_Mutex; - - }; - - } -} - -namespace AEIO = AsuraEngine::IO; - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/io/decoded_data.h b/source/modules/asura-utils/io/decoded_data.h deleted file mode 100644 index 882556c..0000000 --- a/source/modules/asura-utils/io/decoded_data.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __ASURA_ENGINE_DATA_H__ -#define __ASURA_ENGINE_DATA_H__ - -#include - -#include - -#include "../scripting/portable.hpp" - -#include "data_buffer.h" - -namespace AsuraEngine -{ - namespace IO - { - - /// - /// 可以在另一个线程构建的data继承此类。如图片数据、音频数据等,可以在另一个线程中解析原 - /// 文件,生成内部数据格式,如像素等。 - /// - ASURA_ABSTRACT class DecodedData - { - public: - - /// - /// 从内存中构建data,可以放在另一个线程里面,从资源管理系统里面加载。 - /// - DecodedData() {}; - virtual ~DecodedData() {}; - - /// - /// 解码内存中的数据并以某种格式保存。 - /// - virtual void Decode(DataBuffer& buffer) = 0; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/io/file.cpp b/source/modules/asura-utils/io/file.cpp index a2f7403..6d5f4eb 100644 --- a/source/modules/asura-utils/io/file.cpp +++ b/source/modules/asura-utils/io/file.cpp @@ -1,8 +1,8 @@ #include -#include +#include -#include "file.h" +#include "File.h" namespace AsuraEngine { diff --git a/source/modules/asura-utils/io/file.h b/source/modules/asura-utils/io/file.h index 16de42b..d11fa4f 100644 --- a/source/modules/asura-utils/io/file.h +++ b/source/modules/asura-utils/io/file.h @@ -1,12 +1,12 @@ -#ifndef __ASURA_ENGINE_FILE_H__ -#define __ASURA_ENGINE_FILE_H__ +#ifndef _ASURA_ENGINE_FILE_H_ +#define _ASURA_ENGINE_FILE_H_ #include "physfs/physfs.h" -#include "../scripting/portable.hpp" -#include "../threading/thread.h" +#include "../Scripting/Portable.hpp" +#include "../Threads/Thread.h" -#include "file_data.h" +#include "FileData.h" namespace AsuraEngine { diff --git a/source/modules/asura-utils/io/file_data.cpp b/source/modules/asura-utils/io/file_data.cpp deleted file mode 100644 index 30fa5bf..0000000 --- a/source/modules/asura-utils/io/file_data.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "file_data.h" - -namespace AsuraEngine -{ - namespace IO - { - - FileData::FileData(const std::string& filename) - : m_Data(nullptr) - , m_FileName(filename) - { - size_t dot = filename.rfind('.'); - if (dot != std::string::npos) - { - m_Extension = filename.substr(dot + 1); - m_Name = filename.substr(0, dot); - } - else - m_Name = filename; - } - - FileData::~FileData() - { - if (m_Data) - m_Data->Release(); - } - - const std::string& FileData::GetFileName() - { - return m_FileName; - } - - const std::string& FileData::GetExtension() - { - return m_Extension; - } - - const std::string& FileData::GetName() - { - return m_Name; - } - - void FileData::BindData(ASURA_MOVE DataBuffer* buffer) - { - if (!buffer) - return; - if (m_Data) - m_Data->Release(); - m_Data = buffer; - m_Data->Retain(); - } - - DataBuffer* FileData::GetDataBuffer() - { - return m_Data; - } - - } -} \ No newline at end of file diff --git a/source/modules/asura-utils/io/file_data.h b/source/modules/asura-utils/io/file_data.h deleted file mode 100644 index ecc072b..0000000 --- a/source/modules/asura-utils/io/file_data.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __ASURA_ENGINE_FILE_DATA_H__ -#define __ASURA_ENGINE_FILE_DATA_H__ - -#include - -#include - -#include "data_buffer.h" - -namespace AsuraEngine -{ - namespace IO - { - - class Filesystem; - - /// - /// 当从filesystem直接读取整个文件时,返回FileData对象描述文件内容和其他信息。由Filesystem创建。 - /// - class FileData ASURA_FINAL - : public AEScripting::Portable - { - public: - - LUAX_DECL_FACTORY(FileData); - - ~FileData(); - - /// - /// 返回文件内容,可以通过Databuffer获得内容和大小。由于内部接口都是以Data buffer作为参数,所以这里也返回data buffer。 - /// - DataBuffer* GetDataBuffer(); - - const std::string& GetFileName(); - const std::string& GetExtension(); - const std::string& GetName(); - - private: - - friend class Filesystem; - - FileData(const std::string& name); - - /// - /// 绑定data buffer。 - /// - void BindData(ASURA_MOVE DataBuffer* buffer); - - /// - /// Data buffer不会再filedata析构时销毁,当lua引用计数为0时由lua调用GC销毁。创建mData时会添加一个成员引用。 - /// - ASURA_REF DataBuffer* m_Data; - Luax::LuaxMemberRef m_DataRef; - - std::string m_FileName; ///< 包含扩展名的文件名 - std::string m_Extension; ///< 不包含点的扩展名 - std::string m_Name; ///< 不包含点和后缀的文件名 - - LUAX_DECL_METHOD(_GetDataBuffer); - LUAX_DECL_METHOD(_GetFileName); - LUAX_DECL_METHOD(_GetExtension); - LUAX_DECL_METHOD(_GetName); - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/io/file_system.cpp b/source/modules/asura-utils/io/file_system.cpp deleted file mode 100644 index f68bad6..0000000 --- a/source/modules/asura-utils/io/file_system.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include - -#include "../exceptions/exception.h" - -#include "file.h" -#include "file_data.h" -#include "file_system.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace IO - { - -#ifdef ASURA_WINDOWS - #include - #include -#else - #include - #include -#endif - - Filesystem::~Filesystem() - { - if (m_Inited) //PHYSFS_isInit - PHYSFS_deinit(); - } - - void Filesystem::Init(const char* arg0) - { - if (!PHYSFS_init(arg0)) - throw Exception("Failed to initialize filesystem: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); - - m_Inited = true; - } - - bool Filesystem::Mount(const std::string& locpath, const std::string& montpoint/* = "/"*/, bool prepend /*= false*/) - { - if (!m_Inited) - return false; - - return PHYSFS_mount(locpath.c_str(), montpoint.c_str(), !prepend); - } - - bool Filesystem::Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint /*= "/"*/, bool prepend /*= false*/) - { - if (!m_Inited) - return false; - if (PHYSFS_mountMemory(db->GetData(), db->GetSize(), nullptr, archivename.c_str(), mountpoint.c_str(), !prepend)) - { - m_MountData[archivename] = db; - return true; - } - return false; - } - - bool Filesystem::Unmount(const std::string& locpath) - { - if (!m_Inited) - return false; - - // 如果是归档,从映射中删除它 - auto datait = m_MountData.find(locpath); - if (datait != m_MountData.end() && PHYSFS_unmount(locpath.c_str()) != 0) - { - m_MountData.erase(datait); - return true; - } - - return PHYSFS_unmount(locpath.c_str()); - } - - bool Filesystem::Unmount(DataBuffer* db) - { - for (const auto& dp : m_MountData) - { - if (dp.second == db) - { - std::string archive = dp.first; - return Unmount(archive); - } - } - } - - bool Filesystem::GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint) - { - if (!m_Inited) - return false; - const char* point = PHYSFS_getMountPoint(locpath.c_str()); - if (point != nullptr) - { - mountpoint = point; - return true; - } - return false; - } - - void Filesystem::SetWriteDirectory(const std::string locpath) - { - if (!m_Inited) - return; - if (!PHYSFS_setWriteDir(locpath.c_str())) - throw Exception("Failed to set write directory %s", locpath.c_str()); - } - - std::string Filesystem::GetWriteDirectory() - { - return PHYSFS_getWriteDir(); - } - - File* Filesystem::NewFile(const std::string& name) - { - return new File(name); - } - - bool Filesystem::NewDirectory(const std::string& path) - { - if (!m_Inited) - return false; - if (!PHYSFS_getWriteDir()) - return false; - if (!PHYSFS_mkdir(path.c_str())) - return false; - return true; - } - - bool Filesystem::Write(const std::string& name, ASURA_REF DataBuffer* buffer) - { - File file(name); - file.Open(File::FILE_MODE_WRITE); - if (!file.Write(buffer)) - throw Exception("Data could not be written."); - } - - bool Filesystem::Append(const std::string& name, ASURA_REF DataBuffer* buffer) - { - File file(name); - file.Open(File::FILE_MODE_APPEND); - if (!file.Write(buffer)) - throw Exception("Data could not be append."); - } - - FileData* Filesystem::Read(const std::string& name) - { - File file = File(name); - file.Open(File::FILE_MODE_READ); - int size = file.GetSize(); - DataBuffer* db = new DataBuffer(size); - if (db) - { - file.ReadAll(db); - FileData* fd = new FileData(name); - fd->BindData(db); - return fd; - } - return nullptr; - } - - bool Filesystem::Remove(const std::string& path) - { - if (!m_Inited) - return false; - if (PHYSFS_getWriteDir() == 0) - return false; - - if (!PHYSFS_delete(path.c_str())) - return false; - - return true; - } - - bool Filesystem::GetFileInfo(const std::string& filepath, ASURA_OUT FileInfo* info) - { - if (!m_Inited) - return false; - - PHYSFS_Stat stat = {}; - if (!PHYSFS_stat(filepath.c_str(), &stat)) - return false; - - info->size = (int64)stat.filesize; - info->modtime = (int64)stat.modtime; - - if (stat.filetype == PHYSFS_FILETYPE_REGULAR) - info->type = FILE_TYPE_FILE; - else if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY) - info->type = FILE_TYPE_DIRECTORY; - else if (stat.filetype == PHYSFS_FILETYPE_SYMLINK) - info->type = FILE_TYPE_SYMLINK; - else - info->type = FILE_TYPE_OTHER; - - return true; - } - - } -} \ No newline at end of file diff --git a/source/modules/asura-utils/io/file_system.h b/source/modules/asura-utils/io/file_system.h deleted file mode 100644 index 9b4c4be..0000000 --- a/source/modules/asura-utils/io/file_system.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef __ASURA_ENGINE_FILESYSTEM_H__ -#define __ASURA_ENGINE_FILESYSTEM_H__ - -#include -#include - -#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; - }; - - /// - /// 资源管理,负责加载、存储资源,指定根目录等。无论编辑器还是运行时,都需要限制访问的机制,将用户的操作限制在游戏目录 - /// 下,file system就是做这件事的。Filesystem是运行时和编辑器共用的类,AssetDatabase是用来管理资源的类,在framework - /// 里实现,单纯是逻辑处理,读写还是用Filesystem实现,AssetDatabase提供根据文件内容创建对应资源的方法。 - /// - class Filesystem ASURA_FINAL - : public Singleton - , public AEScripting::Portable - { - 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& items) { return false; }; - - private: - - typedef std::map 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 diff --git a/source/modules/asura-utils/io/io_batch_task.cpp b/source/modules/asura-utils/io/io_batch_task.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/io/io_batch_task.h b/source/modules/asura-utils/io/io_batch_task.h deleted file mode 100644 index 0a551e8..0000000 --- a/source/modules/asura-utils/io/io_batch_task.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __ASURA_IO_BATCH_TASK_H__ -#define __ASURA_IO_BATCH_TASK_H__ - -#include "io_task.h" - -namespace AsuraEngine -{ - namespace IO - { - - /// - /// 批量处理读或者写。一次性提交一个table,依次处理后返回结果。 - /// - class IOBatchTask ASURA_FINAL : public AEThreading::Task - { - public: - - private: - - /// - /// 任务表,每一条的结构如下: - /// { path = "", } - /// - Luax::LuaxMemberRef m_Tasks; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/io/io_task.cpp b/source/modules/asura-utils/io/io_task.cpp deleted file mode 100644 index 6c323de..0000000 --- a/source/modules/asura-utils/io/io_task.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "file_system.h" -#include "io_task.h" - -#include - -using namespace AEScripting; -using namespace Luax; - -namespace AsuraEngine -{ - namespace IO - { - - IOTask::IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type) - : m_Path(path) - , m_Buffer(buffer) - { - if (buffer) - buffer->Retain(); - } - - IOTask::~IOTask() - { - if (m_Buffer) - m_Buffer->Release(); - } - - bool IOTask::Execute() - { - File file(m_Path); - if (m_Type == IOTASK_TYPE_WRITE) - { - - } - // 从path读取内容保存在mBuffer中 - else if (m_Type == IOTASK_TYPE_READ) - { - if (!m_Buffer) - return false; - file.Open(File::FILE_MODE_READ); - file.ReadAll(m_Buffer); - file.Close(); - } - return true; - } - - void IOTask::Invoke(lua_State* invokeThreaad) - { - if (m_Callback) - { - LuaxScopedState state(invokeThreaad); - if (this->PushLuaxMemberRef(state, m_Callback)) - { - this->PushLuaxMemberRef(state, m_BufferRef); - state.Call(1, 0); - } - } - } - - } -} diff --git a/source/modules/asura-utils/io/io_task.h b/source/modules/asura-utils/io/io_task.h deleted file mode 100644 index 8026a24..0000000 --- a/source/modules/asura-utils/io/io_task.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __ASURA_IO_TASK_H__ -#define __ASURA_IO_TASK_H__ - -#include - -#include "../scripting/portable.hpp" -#include "../threading/task.h" - -#include "data_buffer.h" - -namespace AsuraEngine -{ - namespace IO - { - - enum IOTaskType - { - IOTASK_TYPE_READ, - IOTASK_TYPE_WRITE, - IOTASK_TYPE_APPEND, - }; - - /// - /// 读取文件任务。 - /// - class IOTask ASURA_FINAL - : public AEScripting::Portable - { - public: - - LUAX_DECL_FACTORY(IOTask); - - IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type); - ~IOTask(); - - bool Execute() override ; - void Invoke(lua_State* invokeThreaad) override; - - private: - - LUAX_DECL_ENUM(IOTaskType); - - LUAX_DECL_METHOD(_New); - - std::string m_Path; - IOTaskType m_Type; - - DataBuffer* m_Buffer; - Luax::LuaxMemberRef m_BufferRef; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/io/renewable.h b/source/modules/asura-utils/io/renewable.h index fd6c638..90867f2 100644 --- a/source/modules/asura-utils/io/renewable.h +++ b/source/modules/asura-utils/io/renewable.h @@ -3,7 +3,7 @@ #include "../scripting/portable.hpp" -#include "decoded_data.h" +#include "DecodedData.h" namespace AsuraEngine { -- cgit v1.1-26-g67d0