| 174 | } |
| 175 | |
| 176 | void ScriptingSystem::reloadScripts() |
| 177 | { |
| 178 | // Release all previously allocated commands |
| 179 | _commands.clear(); |
| 180 | |
| 181 | // Initialise the search's starting point |
| 182 | fs::path start = fs::path(_scriptPath) / COMMAND_PATH; |
| 183 | |
| 184 | if (!fs::exists(start)) |
| 185 | { |
| 186 | rWarning() << "Couldn't find scripts folder: " << start.string() << std::endl; |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | for (fs::recursive_directory_iterator it(start); |
| 191 | it != fs::recursive_directory_iterator(); ++it) |
| 192 | { |
| 193 | // Get the candidate |
| 194 | const fs::path& candidate = *it; |
| 195 | |
| 196 | if (fs::is_directory(candidate)) continue; |
| 197 | |
| 198 | std::string extension = os::getExtension(candidate.string()); |
| 199 | string::to_lower(extension); |
| 200 | |
| 201 | if (extension != PYTHON_FILE_EXTENSION) continue; |
| 202 | |
| 203 | // Script file found, construct a new command |
| 204 | loadCommandScript(os::getRelativePath(candidate.generic_string(), _scriptPath)); |
| 205 | } |
| 206 | |
| 207 | rMessage() << "ScriptModule: Found " << _commands.size() << " commands." << std::endl; |
| 208 | |
| 209 | _sigScriptsReloaded.emit(); |
| 210 | } |
| 211 | |
| 212 | // RegisterableModule implementation |
| 213 | const std::string& ScriptingSystem::getName() const |
nothing calls this directly
no test coverage detected