summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs/asura-lib-utils/filesystem')
-rw-r--r--source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp110
-rw-r--r--source/libs/asura-lib-utils/filesystem/data_buffer.cpp67
-rw-r--r--source/libs/asura-lib-utils/filesystem/data_buffer.h55
-rw-r--r--source/libs/asura-lib-utils/filesystem/decoded_data.cpp20
-rw-r--r--source/libs/asura-lib-utils/filesystem/decoded_data.h42
-rw-r--r--source/libs/asura-lib-utils/filesystem/reloadable.h27
-rw-r--r--source/libs/asura-lib-utils/filesystem/resource_manager.cpp0
-rw-r--r--source/libs/asura-lib-utils/filesystem/resource_manager.h48
8 files changed, 0 insertions, 369 deletions
diff --git a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp b/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
deleted file mode 100644
index 8e92eee..0000000
--- a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "../data_buffer.h"
-
-using namespace Luax;
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- LUAX_REGISTRY(DataBuffer)
- {
- LUAX_REGISTER_METHODS(state,
- { "New", _New },
- { "GetBuffer", _GetBuffer },
- { "GetSize", _GetSize },
- { "Load", _Load },
- { "Clear", _Clear }
- );
- }
-
- LUAX_POSTPROCESS(DataBuffer)
- {
- }
-
- // databuffer = DataBuffer.New(lstring)
- // databuffer = DataBuffer.New(size)
- LUAX_IMPL_METHOD(DataBuffer, _New)
- {
- LUAX_STATE(L);
-
- if (state.IsType(1, LUA_TSTRING))
- {
- byte* bytes;
- size_t size;
- lua_tolstring(L, 1, &size);
- DataBuffer* buffer = new DataBuffer(bytes, size);
- buffer->PushLuaxUserdata(state);
- return 1;
- }
- else if (state.IsType(1, LUA_TNUMBER))
- {
- size_t size = lua_tonumber(L, 1);
- DataBuffer* buffer = new DataBuffer(size);
- buffer->PushLuaxUserdata(state);
- }
- else
- {
- return state.ErrorType(1, "number or string");
- }
- }
-
- // lsting, len = databuffer:GetBuffer()
- LUAX_IMPL_METHOD(DataBuffer, _GetBuffer)
- {
- LUAX_SETUP(L, "U");
-
- DataBuffer* self = state.GetUserdata<DataBuffer>(1);
- lua_pushlstring(L, self->GetBuffer(), self->GetSize());
- return 2;
- }
-
- // length = databuffer:GetSize()
- LUAX_IMPL_METHOD(DataBuffer, _GetSize)
- {
- LUAX_SETUP(L, "U");
-
- DataBuffer* self = state.GetUserdata<DataBuffer>(1);
- lua_pushinteger(L, self->GetSize());
- return 1;
- }
-
- // databuffer:Load(lstring)
- // databuffer:Load(src)
- LUAX_IMPL_METHOD(DataBuffer, _Load)
- {
- LUAX_STATE(L);
-
- DataBuffer* buffer = state.GetUserdata<DataBuffer>(1);
- const byte* data;
- size_t size;
- if (state.IsType(2, LUA_TSTRING))
- {
- data = lua_tolstring(L, 2, &size);
- buffer->Load(data, size);
- return 0;
- }
- else if(state.IsType(2, LUA_TUSERDATA))
- {
- DataBuffer* src = state.CheckUserdata<DataBuffer>(2);
- buffer->Load(*src);
- return 0;
- }
- else
- {
- return state.ErrorType(1, "lstring or DataBuffer");
- }
- }
-
- // databuffer:Clear()
- LUAX_IMPL_METHOD(DataBuffer, _Clear)
- {
- LUAX_SETUP(L, "U");
-
- DataBuffer* self = state.GetUserdata<DataBuffer>(1);
- self->Clear();
- return 0;
- }
-
- }
-} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp b/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
deleted file mode 100644
index 32a123f..0000000
--- a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <cstdlib>
-#include <cstring>
-#include "data_buffer.h"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- DataBuffer::DataBuffer(DataBuffer& src)
- {
- Load(src);
- }
-
- DataBuffer::DataBuffer(std::size_t size)
- : mSize(size)
- , mBytes(nullptr)
- {
- mBytes = new byte[size];
- memset(mBytes, 0, size);
- }
-
- DataBuffer::DataBuffer(const void* data, std::size_t size)
- : mSize(size)
- , mBytes(nullptr)
- {
- Load(data, size);
- }
-
- DataBuffer::~DataBuffer()
- {
- delete[] mBytes;
- }
-
- void DataBuffer::Load(DataBuffer& db)
- {
- Load(db.GetBuffer(), db.GetSize());
- }
-
- void DataBuffer::Load(const void* data, std::size_t size)
- {
- if (!mBytes || mSize != size)
- {
- delete[] mBytes;
- mBytes = new byte[size];
- }
- memcpy(mBytes, data, size);
- }
-
- byte* DataBuffer::GetBuffer()
- {
- return mBytes;
- }
-
- void DataBuffer::Clear()
- {
- if (mBytes)
- memset(mBytes, 0, mSize);
- }
-
- std::size_t DataBuffer::GetSize()
- {
- return mSize;
- }
-
- }
-} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.h b/source/libs/asura-lib-utils/filesystem/data_buffer.h
deleted file mode 100644
index 5c80efb..0000000
--- a/source/libs/asura-lib-utils/filesystem/data_buffer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __ASURA_ENGINE_DATABUFFER_H__
-#define __ASURA_ENGINE_DATABUFFER_H__
-
-#include <cstdlib>
-
-#include "../scripting/portable.hpp"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- ///
- /// ڴݵķװеʹData bufferװֱʹconst void*ͨresource managerȡ
- ///
- class DataBuffer ASURA_FINAL
- : public Scripting::Portable<DataBuffer>
- {
- public:
-
- DataBuffer(DataBuffer& src);
- DataBuffer(std::size_t size);
- DataBuffer(const void* bytes, std::size_t size);
- ~DataBuffer();
-
- byte* GetBuffer();
- size_t GetSize();
-
- void Load(DataBuffer& db);
- void Load(const void* bytes, std::size_t size);
- void Clear();
-
- private:
-
- byte* mBytes;
- size_t mSize;
-
- //------------------------------------------------------------------------------------------------------------
-
- public:
-
- LUAX_DECL_FACTORY(DataBuffer);
-
- LUAX_DECL_METHOD(_New);
- LUAX_DECL_METHOD(_GetBuffer);
- LUAX_DECL_METHOD(_GetSize);
- LUAX_DECL_METHOD(_Load);
- LUAX_DECL_METHOD(_Clear);
-
- };
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/decoded_data.cpp b/source/libs/asura-lib-utils/filesystem/decoded_data.cpp
deleted file mode 100644
index 125c652..0000000
--- a/source/libs/asura-lib-utils/filesystem/decoded_data.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "DecodedData.h"
-#include "Exceptions/Exception.h"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- DecodedData::DecodedData(const DataBuffer* databuffer)
- {
- Decode(databuffer);
- }
-
- DecodedData::~DecodedData()
- {
-
- }
-
- }
-}
diff --git a/source/libs/asura-lib-utils/filesystem/decoded_data.h b/source/libs/asura-lib-utils/filesystem/decoded_data.h
deleted file mode 100644
index 49b5815..0000000
--- a/source/libs/asura-lib-utils/filesystem/decoded_data.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __ASURA_ENGINE_DATA_H__
-#define __ASURA_ENGINE_DATA_H__
-
-#include <cstdlib>
-
-#include "../scripting/portable.hpp"
-
-#include "data_buffer.h"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- ///
- /// һ̹߳data̳дࡣͼƬݡƵݵȣһ߳нԭļڲݸʽ
- /// ȡ
- ///
- ASURA_ABSTRACT class DecodedData
- {
- public:
-
- ///
- /// ڴйdataԷһ߳棬Դϵͳء
- ///
- DecodedData(const DataBuffer& databuffer);
-
- virtual ~DecodedData();
-
- protected:
-
- ///
- /// ڴеݡ
- ///
- virtual void Decode(const DataBuffer& buffer) = 0;
-
- };
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/reloadable.h b/source/libs/asura-lib-utils/filesystem/reloadable.h
deleted file mode 100644
index 7c4ea52..0000000
--- a/source/libs/asura-lib-utils/filesystem/reloadable.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __ASURA_ENGINE_RELOADABLE_H__
-#define __ASURA_ENGINE_RELOADABLE_H__
-
-#include "../scripting/portable.hpp"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- ///
- /// ¹ݽṹͼƬƵ֣ⲿݿֱӹڱ༭¹ڲıhandleԴ
- ///
- ASURA_ABSTRACT class Reloadable
- {
- public:
- Reloadable();
- virtual ~Reloadable();
-
- // ̳ReloadableҪṩһload
-
- };
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.cpp b/source/libs/asura-lib-utils/filesystem/resource_manager.cpp
deleted file mode 100644
index e69de29..0000000
--- a/source/libs/asura-lib-utils/filesystem/resource_manager.cpp
+++ /dev/null
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.h b/source/libs/asura-lib-utils/filesystem/resource_manager.h
deleted file mode 100644
index 36d46cf..0000000
--- a/source/libs/asura-lib-utils/filesystem/resource_manager.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __ASURA_ENGINE_RESOURCE_MANAGER_H__
-#define __ASURA_ENGINE_RESOURCE_MANAGER_H__
-
-#include <string>
-
-#include "../scripting/portable.hpp"
-#include "data_buffer.h"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- ///
- /// Դء洢ԴָĿ¼ȡ
- ///
- class ResourceManager ASURA_FINAL
- {
- public:
-
- ResourceManager();
- ~ResourceManager();
-
- ///
- /// װظĿ¼
- ///
- void Mount(const std::string& root);
-
- ///
- /// ȡļһdata bufferעҪȷȷڴ棬ڵôʹunique_ptr
- ///
- DataBuffer* LoadFile(const std::string& path);
-
- ///
- /// data buffer
- ///
- void SaveFile(const std::string& path, const DataBuffer* buffer);
-
- //----------------------------------------------------------------------------------------------------------
-
- LUAX_DECL_SINGLETON(ResourceManager);
-
- };
-
- }
-}
-
-#endif \ No newline at end of file