summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/io/io_task.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs/asura-lib-utils/io/io_task.cpp')
-rw-r--r--source/libs/asura-lib-utils/io/io_task.cpp25
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);
}
}