MCPcopy Create free account
hub / github.com/DavidColson/Polybox / VfsLoad

Function VfsLoad

source/virtual_filesystem.cpp:57–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55// ***********************************************************************
56
57int VfsLoad(lua_State* L) {
58 u64 filenameLen;
59 const char* filename = luaL_checklstring(L, 1, &filenameLen);
60
61 String realFileName;
62 if (!VFSPathToRealPath(String(filename), realFileName, g_pArenaFrame)) {
63 luaL_error(L, "Filepath not in a valid mount point", filename);
64 return 0;
65 }
66
67
68 i64 fileSize;
69 char* pFileContent = ReadWholeFile(realFileName, &fileSize, g_pArenaFrame);
70 if (pFileContent == nullptr) {
71 luaL_error(L, "Failed to load file %s", filename);
72 return 0;
73 }
74
75 lua_pushlstring(L, pFileContent, fileSize);
76 i32 retVals = Deserialize(L);
77
78 // this function expects the table to be hot reloaded is on the top of the stack
79 Cpu::EnableHotReloadForFile(L, realFileName);
80 return retVals;
81}
82
83// ***********************************************************************
84

Callers

nothing calls this directly

Calls 4

VFSPathToRealPathFunction · 0.85
DeserializeFunction · 0.85
EnableHotReloadForFileFunction · 0.85
StringClass · 0.70

Tested by

no test coverage detected