diff options
author | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
commit | f4c338c63f3456a8eccd56c35e233843687d55be (patch) | |
tree | 7278fe4723320c9ef310c5a04d92bf0be1bc778c /source/libs/asura-lib-utils/io/io_task.cpp | |
parent | 3bced067a4144381e59ce4bd0eb749eeff5ad1f4 (diff) |
*thread
Diffstat (limited to 'source/libs/asura-lib-utils/io/io_task.cpp')
-rw-r--r-- | source/libs/asura-lib-utils/io/io_task.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/source/libs/asura-lib-utils/io/io_task.cpp b/source/libs/asura-lib-utils/io/io_task.cpp index 1a50e56..7203175 100644 --- a/source/libs/asura-lib-utils/io/io_task.cpp +++ b/source/libs/asura-lib-utils/io/io_task.cpp @@ -1,5 +1,8 @@ +#include "file_system.h" #include "io_task.h" +#include <iostream> + using namespace AEScripting; using namespace Luax; @@ -8,9 +11,9 @@ namespace AsuraEngine namespace IO { - IOTask::IOTask(const std::string& path, DataBuffer* buffer) + IOTask::IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type) : mPath(path) - , mDst(buffer) + , mBuffer(buffer) { } @@ -20,17 +23,29 @@ namespace AsuraEngine bool IOTask::Execute() { + File file(mPath); + if (mType == IOTASK_TYPE_WRITE) + { + + } + // pathȡݱmBuffer + else if (mType == IOTASK_TYPE_READ) + { + file.Open(File::FILE_MODE_READ); + file.ReadAll(mBuffer); + file.Close(); + } return true; } - void IOTask::Invoke(lua_State* thread) + void IOTask::Invoke() { if (mCallback) { - LuaxScopedState state(thread); + LuaxScopedState state(LuaEnv::Get()->GetMainState()); if (PushLuaxMemberRef(state, mCallback)) { - PushLuaxMemberRef(state, mDstRef); + PushLuaxMemberRef(state, mBufferRef); state.Call(1, 0); } } |