MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / evalFile

Method evalFile

src/app/script/app_scripting.cpp:194–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192 }
193
194 bool AppScripting::evalFile(const std::string& fileName) {
195 m_fileName = fileName;
196 std::cout << "Reading file " << fileName << std::endl;
197 std::ifstream ifs(fileName);
198 if (!ifs) {
199 std::cout << "Could not open " << fileName << std::endl;
200 return false;
201 }
202
203 auto extension = base::string_to_lower(base::get_file_extension(fileName));
204 script::Engine::setDefault(extension, {extension});
205
206 engine = nullptr;
207
208 AppScripting instance;
209 if (!instance.eval({std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>()}))
210 return false;
211
212 engine->raiseEvent({"init"});
213
214 previousFileName = fileName;
215 return true;
216 }
217
218 void AppScripting::printLastResult() {
219 if(engine)

Callers 1

initializeMethod · 0.80

Calls 4

string_to_lowerFunction · 0.85
get_file_extensionFunction · 0.85
evalMethod · 0.45
raiseEventMethod · 0.45

Tested by

no test coverage detected