From f52ef1501be91d379f83c46c71eb610c96294c91 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Wed, 5 Jun 2013 14:13:47 +0100 Subject: [PATCH] Implemented issue #4 --- src/backend/metadata.cpp | 18 +++++++++++++++++- src/backend/metadata.h | 2 +- src/backend/parsers.h | 4 ---- src/gui/main.cpp | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 71a69411..6317838b 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -201,7 +201,11 @@ namespace boss { } Plugin::Plugin() : enabled(true), priority(0), isMaster(false) {} - Plugin::Plugin(const std::string& n) : name(n), enabled(true), priority(0), isMaster(false) {} + Plugin::Plugin(const std::string& n) : name(n), enabled(true), priority(0), isMaster(false) { + //If the name passed ends in '.ghost', that should be trimmed. + if (boost::iends_with(name, ".ghost")) + name = name.substr(0, name.length() - 6); + } Plugin::Plugin(boss::Game& game, const std::string& n, const bool headerOnly) : name(n), enabled(true), priority(0) { @@ -218,6 +222,10 @@ namespace boss { plugins.push_back(name); for (vector::const_iterator it = records.begin(),endIt = records.end(); it != endIt; ++it) formIDs.insert(FormID(plugins, *it)); + + //If the name passed ends in '.ghost', that should be trimmed. + if (boost::iends_with(name, ".ghost")) + name = name.substr(0, name.length() - 6); //Also read Bash Tags applied and version string in description. for(size_t i=0,max=file.fields.size(); i < max; ++i){ @@ -554,4 +562,12 @@ namespace boss { return boost::ilexicographical_compare(lhs.Name(), rhs.Name()); } + + bool IsPlugin(const std::string& file) { + if (boost::iends_with(file, ".esp") || boost::iends_with(file, ".esm") + || boost::iends_with(file, ".esp.ghost") || boost::iends_with(file, ".esm.ghost")) + return true; + else + return false; + } } diff --git a/src/backend/metadata.h b/src/backend/metadata.h index cedfaa54..4ad654f8 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -186,7 +186,7 @@ namespace boss { bool load_order_sort(const Plugin& lhs, const Plugin& rhs); - + bool IsPlugin(const std::string& file); } #endif diff --git a/src/backend/parsers.h b/src/backend/parsers.h index 092ce55a..b323a5e3 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -498,10 +498,6 @@ namespace boss { result = game->IsActive(file); } - bool IsPlugin(const std::string& file) { - return boost::iends_with(file, ".esm") || boost::iends_with(file, ".esp"); - } - void SyntaxError(Iterator const& /*first*/, Iterator const& last, Iterator const& errorpos, boost::spirit::info const& what) { std::string context(errorpos, min(errorpos +50, last)); diff --git a/src/gui/main.cpp b/src/gui/main.cpp index e0527b09..f67239b4 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -326,7 +326,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { // Get a list of the plugins. list plugins; for (fs::directory_iterator it(_game.DataPath()); it != fs::directory_iterator(); ++it) { - if (fs::is_regular_file(it->status()) && (it->path().extension().string() == ".esp" || it->path().extension().string() == ".esm")) { + if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { string filename = it->path().filename().string(); out << "Reading plugin: " << filename << endl; @@ -577,7 +577,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { //Scan for installed plugins. for (fs::directory_iterator it(_game.DataPath()); it != fs::directory_iterator(); ++it) { - if (fs::is_regular_file(it->status()) && (it->path().extension().string() == ".esp" || it->path().extension().string() == ".esm")) { + if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { boss::Plugin plugin(_game, it->path().filename().string(), true); installed.push_back(plugin);