diff options
author | chai <chaifix@163.com> | 2019-03-26 09:09:02 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-26 09:09:02 +0800 |
commit | d9041d6e12ded456c17622f7f2e7bbacb9e99b1a (patch) | |
tree | 6fd4febeb79b9b5efb5341ea352e05cd7752f5e8 /source/tests/05-physfs/main.cpp | |
parent | 70f8aa8d1a3c15bd1eee3cdd88b9b9ce8970fae5 (diff) |
*misc
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 |