MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / loadFile

Method loadFile

MonaServer/sources/Service.cpp:224–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void Service::loadFile() {
225
226 open(true);
227
228 _ex.set(Exception::NIL);
229
230 SCRIPT_BEGIN(_pState)
231
232 lua_rawgeti(_pState, LUA_REGISTRYINDEX, _reference);
233 if(luaL_loadfile(_pState,file.path().c_str())!=0) {
234 SCRIPT_ERROR(_ex.set(Exception::SOFTWARE, Script::LastError(_pState)).error())
235 lua_pop(_pState,1); // remove environment
236 return;
237 }
238
239 // set environment
240 lua_pushvalue(_pState, -2);
241 lua_setfenv(_pState, -2);
242
243 if(lua_pcall(_pState, 0,0, 0)==0) {
244 SCRIPT_FUNCTION_BEGIN("onStart",_reference)
245 SCRIPT_WRITE_STRING(path.c_str())
246 SCRIPT_FUNCTION_CALL
247 SCRIPT_FUNCTION_END
248 _handler.startService(*this);
249 SCRIPT_INFO("Application www", path, " loaded")
250 } else {
251 SCRIPT_ERROR(_ex.set(Exception::SOFTWARE, Script::LastError(_pState)).error());
252 clearEnvironment();
253 }
254
255 lua_pop(_pState, 1);
256
257 SCRIPT_END
258}
259
260void Service::close(bool full) {
261

Callers

nothing calls this directly

Calls 2

errorMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected