MCPcopy Create free account
hub / github.com/InoriRus/Kyty / RunFile

Function RunFile

source/lib/Scripts/src/Scripts.cpp:183–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183ScriptError RunFile(const String& file_name)
184{
185 lua_init();
186 // EXIT_IF(lua_gettop(g_lua_state) > 0);
187
188 File f(file_name, File::Mode::Read);
189 f.SetEncoding(File::Encoding::Utf8);
190
191 if (f.IsInvalid())
192 {
193 return ScriptError::FileError;
194 }
195
196 String str = f.ReadWholeString();
197 f.Close();
198
199 // TODO(#117): load and run binary files
200
201 ScriptError status = LoadString(str);
202
203 if (status != ScriptError::Ok)
204 {
205 return status;
206 }
207
208 status = Run();
209
210 return status;
211}
212
213ScriptError RunString(const String& source)
214{

Callers 3

run_scriptFunction · 0.85
RunScriptFunction · 0.85
KYTY_STATIC_SCRIPT_FUNCFunction · 0.85

Calls 7

lua_initFunction · 0.85
RunFunction · 0.85
SetEncodingMethod · 0.80
ReadWholeStringMethod · 0.80
LoadStringFunction · 0.70
IsInvalidMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected