Don't complain about things in the autoload folder which aren't automation scripts

This commit is contained in:
Thomas Goyne 2013-02-07 15:58:51 -08:00
parent a872fc50b8
commit d3606eac99
2 changed files with 6 additions and 6 deletions

View file

@ -358,7 +358,7 @@ namespace Automation4 {
if (!agi::fs::DirectoryExists(dirname)) continue;
for (auto filename : agi::fs::DirectoryIterator(dirname, "*.*")) {
Script *s = ScriptFactory::CreateFromFile(dirname/filename, true);
Script *s = ScriptFactory::CreateFromFile(dirname/filename, false, false);
if (s) {
scripts.push_back(s);
if (!s->GetLoadedState()) ++error_count;
@ -480,19 +480,19 @@ namespace Automation4 {
}
}
Script* ScriptFactory::CreateFromFile(agi::fs::path const& filename, bool log_errors, bool create_unknown)
Script* ScriptFactory::CreateFromFile(agi::fs::path const& filename, bool complain_about_unrecognised, bool create_unknown)
{
for (auto factory : Factories()) {
Script *s = factory->Produce(filename);
if (s) {
if (!s->GetLoadedState() && log_errors) {
if (!s->GetLoadedState()) {
wxLogError(_("An Automation script failed to load. File name: '%s', error reported: %s"), filename.wstring(), s->GetDescription());
}
return s;
}
}
if (log_errors) {
if (complain_about_unrecognised) {
wxLogError(_("The file was not recognised as an Automation script: %s"), filename.wstring());
}

View file

@ -274,9 +274,9 @@ namespace Automation4 {
/// Load a script from a file
/// @param filename Script to load
/// @param log_errors Should load errors be displayed?
/// @param complain_about_unrecognised Should an error be displayed for files that aren't automation scripts?
/// @param create_unknown Create a placeholder rather than returning nullptr if no script engine supports the file
static Script* CreateFromFile(agi::fs::path const& filename, bool log_errors, bool create_unknown=true);
static Script* CreateFromFile(agi::fs::path const& filename, bool complain_about_unrecognised, bool create_unknown=true);
static const std::vector<ScriptFactory*>& GetFactories();
};