diff options
Diffstat (limited to 'source/tests/05-physfs/main.cpp')
-rw-r--r-- | source/tests/05-physfs/main.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
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 <string> + +#include <asura-lib-utils/utils.h> + +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 |