From d9041d6e12ded456c17622f7f2e7bbacb9e99b1a Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 26 Mar 2019 09:09:02 +0800 Subject: *misc --- source/tests/05-physfs/main.cpp | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 source/tests/05-physfs/main.cpp (limited to 'source/tests/05-physfs/main.cpp') diff --git a/source/tests/05-physfs/main.cpp b/source/tests/05-physfs/main.cpp new file mode 100644 index 0000000..454d6cf --- /dev/null +++ b/source/tests/05-physfs/main.cpp @@ -0,0 +1,54 @@ +#include + +#include + +using namespace Luax; +using namespace std; + +string code = R"( +function main() + local suc = Filesystem.Init(arg0) + print(suc) + suc = Filesystem.Mount("./", "root", true) + print(suc) + Filesystem.SetWriteDirectory("./") + local databuffer = DataBuffer.New(1024) + local str = "hello, worldÄãºÃ" + databuffer:Refactor(#str) + databuffer:Load(str) + local file = Filesystem.CreateFile("physfs.txt") + file:Open(EFileMode.WRITE) + file:Write(databuffer) + file:Close() + print(file:GetFileName()) + print(file:GetExtension()) + print(file:GetName()) + + io.read() +end + +function err(msg) + print(msg) +end + +xpcall(main, err) +)"; + +int main(int argc, char* args[]) +{ + AsuraEngine::UtilsModule utils; + + lua_State* L = LuaxRuntime::Get().Open(); + LuaxState& state = LuaxRuntime::Get().GetLuaxState(L); + state.OpenLibs(); + state.PushGlobalNamespace(); + if(argc > 0) + state.SetField(-1, "arg0", args[0]); + utils.Initialize(state); + state.PopNamespace(); + state.DoString(code); + + LuaxRuntime::Get().Close(L); + + return 0; +} \ No newline at end of file -- cgit v1.1-26-g67d0