diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 5b3c8a63..5e02c0cd 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -98,7 +98,7 @@ namespace boss { bossFolderName = folder; if (fs::exists(libespm_options_path)) - espm_settings = espm::Settings(libespm_options_path, libespmGame); + espm_settings = espm::Settings(libespm_options_path.string(), libespmGame); else throw error(ERROR_PATH_NOT_FOUND, "Libespm settings file could not be found."); } diff --git a/src/backend/globals.h b/src/backend/globals.h index cb933dca..64f5b215 100644 --- a/src/backend/globals.h +++ b/src/backend/globals.h @@ -50,10 +50,12 @@ namespace boss { const unsigned int VERSION_PATCH = 0; //Common paths. - const boost::filesystem::path settings_path = "resources/settings.yaml"; - const boost::filesystem::path log_path = "BOSSDebugLog.txt"; - const boost::filesystem::path readme_path = boost::filesystem::path("Docs") / "BOSS Readme.html"; - const char * const libespm_options_path = "resources/libespm.yaml"; + const boost::filesystem::path readme_path = "Docs/BOSS Readme.html"; + const boost::filesystem::path settings_path = "resources/settings.yaml"; + const boost::filesystem::path libespm_options_path = "resources/libespm.yaml"; + const boost::filesystem::path svn_path = "resources/svn/svn.exe"; + const boost::filesystem::path log_path = "BOSSDebugLog.txt"; + const boost::filesystem::path svn_log_path = "svn.log"; } #endif diff --git a/src/backend/network.cpp b/src/backend/network.cpp index d9d1be09..d80ae5db 100644 --- a/src/backend/network.cpp +++ b/src/backend/network.cpp @@ -33,37 +33,46 @@ namespace fs = boost::filesystem; namespace boss { - unsigned int UpdateMasterlist(const Game& game) { + unsigned int UpdateMasterlist(const Game& game, std::vector& parsingErrors) { + string command; //First check if the working copy is set up or not. - int ret = system(("resources\\svn\\svn.exe info " + game.MasterlistPath().parent_path().string() + " > svn.log").c_str()); + command = svn_path.string() + " info " + game.MasterlistPath().parent_path().string() + " > " + svn_log_path.string(); - if (ret != 0) { + if (system(command.c_str()) != 0) { //Working copy not set up, perform a checkout. - ret = system(("resources\\svn\\svn.exe co --depth empty " + game.URL().substr(0, game.URL().rfind('/')) + " " + game.MasterlistPath().parent_path().string() + "/. > svn.log").c_str()); + command = svn_path.string() + " co --depth empty " + game.URL().substr(0, game.URL().rfind('/')) + " " + game.MasterlistPath().parent_path().string() + "/. > " + svn_log_path.string(); + if (system(command.c_str()) != 0) + throw error(ERROR_SUBVERSION_ERROR, "Subversion could not perform a checkout. See " + svn_log_path.string() + " in the BOSS folder for details."); } //Now update masterlist. - ret = system(("resources\\svn\\svn.exe update " + game.MasterlistPath().string() + " > svn.log").c_str()); + command = svn_path.string() + " update " + game.MasterlistPath().string() + " > " + svn_log_path.string(); + if (system(command.c_str()) != 0) + throw error(ERROR_SUBVERSION_ERROR, "Subversion could not update the masterlist. See " + svn_log_path.string() + " in the BOSS folder for details."); //Now test masterlist to see if it parses OK. - ret = 1; - while (ret == 1) { + bool good = false; + while (!good) { try { YAML::Node mlist = YAML::LoadFile(game.MasterlistPath().string()); - ret = 0; + good = true; } catch (YAML::Exception& e) { //Roll back one revision if there's an error. - ret = system(("resources\\svn\\svn.exe update --revision PREV " + game.MasterlistPath().string() + " > svn.log").c_str()); - ret = 1; + parsingErrors.push_back(e.what()); + command = svn_path.string() + " update --revision PREV " + game.MasterlistPath().string() + " > " + svn_log_path.string(); + if (system(command.c_str()) != 0) + throw error(ERROR_SUBVERSION_ERROR, "Subversion could not update the masterlist. See " + svn_log_path.string() + " in the BOSS folder for details."); } } //Now get the masterlist revision. Can either create a pipe using the Win32 API (http://msdn.microsoft.com/en-us/library/ms682499.aspx), or output to a file, read it, then delete it. - ret = system(("resources\\svn\\svn.exe info " + game.MasterlistPath().string() + " > svn.log").c_str()); + command = svn_path.string() + " info " + game.MasterlistPath().parent_path().string() + " > " + svn_log_path.string(); + if (system(command.c_str()) != 0) + throw error(ERROR_SUBVERSION_ERROR, "Subversion could not read the masterlist revision number. See " + svn_log_path.string() + " in the BOSS folder for details."); - ifstream in("svn.log"); + ifstream in(svn_log_path.string().c_str()); - int revision; + int revision = 0; while (in.good()) { string line; getline(in, line); @@ -73,7 +82,7 @@ namespace boss { } in.close(); - fs::remove("svn.log"); + fs::remove(svn_log_path); return revision; } diff --git a/src/backend/network.h b/src/backend/network.h index 421b304e..ed30be63 100644 --- a/src/backend/network.h +++ b/src/backend/network.h @@ -57,6 +57,6 @@ namespace boss { ```svn info masterlist.txt``` returns a bunch of info: the line "Revision: XXXX" contains the revision number. */ - unsigned int UpdateMasterlist(const Game& game); + unsigned int UpdateMasterlist(const Game& game, std::vector& parsingErrors); } #endif diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 99619850..f07be18d 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -322,7 +322,18 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { out << "Updating masterlist..." << endl; - UpdateMasterlist(_game); + vector parsingErrors; + try { + UpdateMasterlist(_game, parsingErrors); + } catch (boss::error& e) { + //LOG_ERROR("Error: %s", e.what()); + wxMessageBox( + FromUTF8(format(loc::translate("Error: Condition evaluation failed. %1%")) % e.what()), + translate("BOSS: Error"), + wxOK | wxICON_ERROR, + this); + return; + } out << "Reading plugins in Data folder..." << endl; time_t start, end;