| 29 | #include "json.h" |
| 30 | |
| 31 | static std::string getFullPath(const std::string &fileName, const std::string &exename, bool debug = false) { |
| 32 | if (debug) |
| 33 | std::cout << "looking for addon '" << fileName << "'" << std::endl; |
| 34 | if (Path::isFile(fileName)) |
| 35 | return fileName; |
| 36 | |
| 37 | const bool is_abs_path = Path::isAbsolute(fileName); |
| 38 | if (is_abs_path) |
| 39 | return ""; |
| 40 | |
| 41 | const std::string exepath = Path::getPathFromFilename(exename); |
| 42 | { |
| 43 | std::string p = Path::join(exepath, fileName); |
| 44 | if (debug) |
| 45 | std::cout << "looking for addon '" << p << "'" << std::endl; |
| 46 | if (Path::isFile(p)) |
| 47 | return p; |
| 48 | } |
| 49 | { |
| 50 | std::string p = Path::join(exepath, "addons", fileName); |
| 51 | if (debug) |
| 52 | std::cout << "looking for addon '" << p << "'" << std::endl; |
| 53 | if (Path::isFile(p)) |
| 54 | return p; |
| 55 | } |
| 56 | |
| 57 | #ifdef FILESDIR |
| 58 | { |
| 59 | std::string p = Path::join(FILESDIR, fileName); |
| 60 | if (debug) |
| 61 | std::cout << "looking for addon '" << p << "'" << std::endl; |
| 62 | if (Path::isFile(p)) |
| 63 | return p; |
| 64 | } |
| 65 | { |
| 66 | std::string p = Path::join(FILESDIR, "addons", fileName); |
| 67 | if (debug) |
| 68 | std::cout << "looking for addon '" << p << "'" << std::endl; |
| 69 | if (Path::isFile(p)) |
| 70 | return p; |
| 71 | } |
| 72 | #endif |
| 73 | return ""; |
| 74 | } |
| 75 | |
| 76 | static std::string parseAddonInfo(AddonInfo& addoninfo, const picojson::value &json, const std::string &fileName, const std::string &exename) { |
| 77 | const std::string& json_error = picojson::get_last_error(); |
no test coverage detected