MCPcopy Create free account
hub / github.com/crownengine/crown / luaL_loadfilex

Function luaL_loadfilex

3rdparty/luajit/src/lj_load.c:84–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename,
85 const char *mode)
86{
87 FileReaderCtx ctx;
88 int status;
89 const char *chunkname;
90 if (filename) {
91 ctx.fp = fopen(filename, "rb");
92 if (ctx.fp == NULL) {
93 lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno));
94 return LUA_ERRFILE;
95 }
96 chunkname = lua_pushfstring(L, "@%s", filename);
97 } else {
98 ctx.fp = stdin;
99 chunkname = "=stdin";
100 }
101 status = lua_loadx(L, reader_file, &ctx, chunkname, mode);
102 if (ferror(ctx.fp)) {
103 L->top -= filename ? 2 : 1;
104 lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno));
105 if (filename)
106 fclose(ctx.fp);
107 return LUA_ERRFILE;
108 }
109 if (filename) {
110 L->top--;
111 copyTV(L, L->top-1, L->top);
112 fclose(ctx.fp);
113 }
114 return status;
115}
116
117LUALIB_API int luaL_loadfile(lua_State *L, const char *filename)
118{

Callers 2

lib_base.cFile · 0.85
luaL_loadfileFunction · 0.85

Calls 6

fopenFunction · 0.85
lua_loadxFunction · 0.85
ferrorFunction · 0.85
fcloseFunction · 0.85
copyTVFunction · 0.85
lua_pushfstringFunction · 0.70

Tested by

no test coverage detected