diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index b5b7384ef..38857a6ca 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -163,7 +163,7 @@ void CollectionSystemManager::saveCustomCollection(SystemData* sys) } } else { - LOG(LogError) << "Couldn't find collection to save! " << name; + LOG(LogError) << "Couldn't find collection to save: " << name; } } @@ -888,10 +888,10 @@ void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sys std::string path = getCustomCollectionConfigPath(newSys->getName()); if (!Utils::FileSystem::exists(path)) { - LOG(LogInfo) << "Couldn't find custom collection config file at " << path; + LOG(LogInfo) << "Couldn't find custom collection config file \"" << path << "\""; return; } - LOG(LogInfo) << "Loading custom collection config file at " << path; + LOG(LogInfo) << "Parsing custom collection file \"" << path << "\"..."; FileData* rootFolder = newSys->getRootFolder(); FileFilterIndex* index = newSys->getIndex(); @@ -928,8 +928,7 @@ void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sys index->addToIndex(newGame); } else { - LOG(LogInfo) << "Couldn't find game referenced at '" << gameKey << - "' for system config '" << path << "'"; + LOG(LogWarning) << "File \"" << gameKey << "\" does not exist, ignoring entry"; } } diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index 69073291d..6311b23a1 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -27,7 +27,7 @@ FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType std::string relative = Utils::FileSystem::removeCommonPath(path, root->getPath(), contains); if (!contains) { - LOG(LogError) << "File path \"" << path << "\" is outside system path \"" << + LOG(LogError) << "Path \"" << path << "\" is outside system path \"" << system->getStartPath() << "\""; return nullptr; } @@ -52,7 +52,7 @@ FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType return treeNode; if (type == FOLDER) { - LOG(LogWarning) << "Gamelist: folder doesn't exist, won't create"; + LOG(LogWarning) << "Gamelist: folder doesn't exist, won't create it"; return nullptr; } @@ -68,7 +68,7 @@ FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType // Don't create folders unless they're including any games. // If the type is FOLDER it's going to be empty, so don't bother. if (type == FOLDER) { - LOG(LogWarning) << "Gamelist: folder doesn't exist, won't create"; + LOG(LogWarning) << "Gamelist: folder doesn't exist, won't create it"; return nullptr; } @@ -93,7 +93,7 @@ void parseGamelist(SystemData* system) if (!Utils::FileSystem::exists(xmlpath)) return; - LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; + LOG(LogInfo) << "Parsing gamelist file \"" << xmlpath << "\"..."; pugi::xml_document doc; #if defined(_WIN64) @@ -104,14 +104,14 @@ void parseGamelist(SystemData* system) #endif if (!result) { - LOG(LogError) << "Error parsing XML file \"" << xmlpath << - "\"!\n " < node in gamelist \"" << xmlpath << "\"!"; + LOG(LogError) << "Could not find node in gamelist \"" << xmlpath << "\""; return; } @@ -130,7 +130,8 @@ void parseGamelist(SystemData* system) relativeTo, false); if (!trustGamelist && !Utils::FileSystem::exists(path)) { - LOG(LogWarning) << "File \"" << path << "\" does not exist, ignoring."; + LOG(LogWarning) << (type == GAME ? "File \"" : "Folder \"") << path << + "\" does not exist, ignoring entry"; continue; } @@ -138,14 +139,15 @@ void parseGamelist(SystemData* system) // it is located. if (!showHiddenFiles && (Utils::FileSystem::isHidden(path) || Utils::FileSystem::isHidden(Utils::FileSystem::getParent(path)))) { - LOG(LogDebug) << "Gamelist::parseGamelist(): Skipping hidden file " << path; + LOG(LogDebug) << "Gamelist::parseGamelist(): Skipping hidden file \"" << + path << "\""; continue; } FileData* file = findOrCreateFile(system, path, type); if (!file) { LOG(LogError) << "Error finding/creating FileData for \"" << - path << "\", skipping."; + path << "\", skipping entry"; continue; } else if (!file->isArcadeAsset()) { @@ -163,8 +165,9 @@ void parseGamelist(SystemData* system) // but that is fine as the option to show hidden files is defined as requiring an // application restart. if (!Settings::getInstance()->getBool("ShowHiddenGames") && file->getHidden()) { - LOG(LogDebug) << "Gamelist::parseGamelist(): Skipping hidden entry '" << - file->getName() << "'" << " (" << file->getPath() << ")."; + LOG(LogDebug) << "Gamelist::parseGamelist(): Skipping hidden " << + (type == GAME ? "file" : "folder") << " entry \"" << + file->getName() << "\"" << " (\"" << file->getPath() << "\")"; delete file; } } @@ -223,7 +226,7 @@ void updateGamelist(SystemData* system) #endif if (!result) { - LOG(LogError) << "Error parsing XML file \"" << xmlReadPath << "\"!\n " << + LOG(LogError) << "Error parsing gamelist file \"" << xmlReadPath << "\": " << result.description(); return; } @@ -231,7 +234,7 @@ void updateGamelist(SystemData* system) root = doc.child("gameList"); if (!root) { LOG(LogError) << "Could not find node in gamelist \"" << - xmlReadPath << "\"!"; + xmlReadPath << "\""; return; } } @@ -263,7 +266,7 @@ void updateGamelist(SystemData* system) fileNode = fileNode.next_sibling(tag)) { pugi::xml_node pathNode = fileNode.child("path"); if (!pathNode) { - LOG(LogError) << "<" << tag << "> node contains no child!"; + LOG(LogError) << "<" << tag << "> node contains no child"; continue; } @@ -296,7 +299,7 @@ void updateGamelist(SystemData* system) Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(xmlWritePath)); LOG(LogDebug) << "Gamelist::updateGamelist(): Added/updated " << numUpdated << - (numUpdated == 1 ? " entity in '" : " entities in '") << xmlReadPath << "'"; + (numUpdated == 1 ? " entity in '" : " entities in \"") << xmlReadPath << "\""; #if defined(_WIN64) if (!doc.save_file(Utils::String::stringToWideString(xmlWritePath).c_str())) { @@ -304,11 +307,11 @@ void updateGamelist(SystemData* system) if (!doc.save_file(xmlWritePath.c_str())) { #endif LOG(LogError) << "Error saving gamelist.xml to \"" << - xmlWritePath << "\" (for system " << system->getName() << ")!"; + xmlWritePath << "\" (for system " << system->getName() << ")"; } } } else { - LOG(LogError) << "Found no root folder for system \"" << system->getName() << "\"!"; + LOG(LogError) << "Found no root folder for system \"" << system->getName() << "\""; } } diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 4c5f0d200..6075a5900 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -104,12 +104,12 @@ bool SystemData::populateFolder(FileData* folder) const std::string& folderPath = folder->getPath(); if (!Utils::FileSystem::exists(folderPath)) { LOG(LogDebug) << "SystemData::populateFolder(): Folder with path \"" << - folderPath << "\" does not exist."; + folderPath << "\" does not exist"; return false; } if (!Utils::FileSystem::isDirectory(folderPath)) { LOG(LogWarning) << "Folder with path \"" << - folderPath << "\" is not a directory."; + folderPath << "\" is not a directory"; return false; } @@ -139,8 +139,12 @@ bool SystemData::populateFolder(FileData* folder) filePath = *it; // Skip hidden files and folders. - if (!showHiddenFiles && Utils::FileSystem::isHidden(filePath)) + if (!showHiddenFiles && Utils::FileSystem::isHidden(filePath)) { + LOG(LogDebug) << "SystemData::populateFolder(): Skipping hidden " << + (Utils::FileSystem::isDirectory(filePath) ? "directory \"" : "file \"") << + filePath << "\""; continue; + } // This is a little complicated because we allow a list // of extensions to be defined (delimited with a space). @@ -221,17 +225,17 @@ bool SystemData::loadConfig() deleteSystems(); std::string path = getConfigPath(false); - const std::string rompath = FileData::getROMDirectory(); - - LOG(LogInfo) << "Loading system configuration file " << path << "..."; + const std::string rompath = FileData::getROMDirectory(); if (!Utils::FileSystem::exists(path)) { - LOG(LogWarning) << "es_systems.cfg does not exist."; + LOG(LogWarning) << "Systems configuration file does not exist"; if (copyConfigTemplate(getConfigPath(true))) return false; path = getConfigPath(false); } + LOG(LogInfo) << "Parsing systems configuration file \"" << path << "\"..."; + pugi::xml_document doc; #if defined(_WIN64) pugi::xml_parse_result res = doc.load_file(Utils::String::stringToWideString(path).c_str()); @@ -249,7 +253,7 @@ bool SystemData::loadConfig() pugi::xml_node systemList = doc.child("systemList"); if (!systemList) { - LOG(LogError) << "es_systems.cfg is missing the tag."; + LOG(LogError) << "es_systems.cfg is missing the tag"; return false; } @@ -307,7 +311,7 @@ bool SystemData::loadConfig() // Validate. if (name.empty() || path.empty() || extensions.empty() || cmd.empty()) { LOG(LogError) << "System \"" << name << - "\" is missing name, path, extension, or command."; + "\" is missing name, path, extension, or command"; continue; } @@ -349,7 +353,7 @@ bool SystemData::loadConfig() if (newSys->getRootFolder()->getChildrenByFilename().size() == 0 || onlyHidden) { LOG(LogDebug) << "SystemData::loadConfig(): System \"" << name << - "\" has no games, ignoring it."; + "\" has no games, ignoring it"; delete newSys; delete envData; } @@ -374,25 +378,30 @@ bool SystemData::copyConfigTemplate(const std::string& path) { std::string systemsTemplateFile;; - LOG(LogInfo) << "Attempting to copy template es_systems.cfg file from the resources directory."; + LOG(LogInfo) << + "Attempting to copy template es_systems.cfg file from the resources directory..."; #if defined(_WIN64) systemsTemplateFile = ResourceManager::getInstance()-> - getResourcePath(":/templates/es_systems.cfg_windows"); + getResourcePath(":/templates/es_systems.cfg_windows", false); #elif defined(__APPLE__) systemsTemplateFile = ResourceManager::getInstance()-> - getResourcePath(":/templates/es_systems.cfg_macos"); + getResourcePath(":/templates/es_systems.cfg_macos", false); #elif defined(__unix__) systemsTemplateFile = ResourceManager::getInstance()-> - getResourcePath(":/templates/es_systems.cfg_unix"); + getResourcePath(":/templates/es_systems.cfg_unix", false); #endif - if (Utils::FileSystem::copyFile(systemsTemplateFile, path, false)) { - LOG(LogError) << "Copying of es_systems.cfg template file failed."; + if (systemsTemplateFile == "") { + LOG(LogError) << "Can't find the es_systems.cfg template file"; + return true; + } + else if (Utils::FileSystem::copyFile(systemsTemplateFile, path, false)) { + LOG(LogError) << "Copying of es_systems.cfg template file failed"; return true; } - LOG(LogInfo) << "Template es_systems.cfg file copied successfully."; + LOG(LogInfo) << "Template es_systems.cfg file copied successfully"; return false; } diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 8ecc34f31..8c0303bbb 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -361,7 +361,7 @@ bool verifyHomeFolderExists() returnCode loadSystemConfigFile(std::string& errorMsg) { if (!SystemData::loadConfig()) { - LOG(LogError) << "Could not parse systems configuration file."; + LOG(LogError) << "Could not parse systems configuration file"; errorMsg = "COULDN'T FIND THE SYSTEMS CONFIGURATION FILE.\n" "ATTEMPTED TO COPY A TEMPLATE ES_SYSTEMS.CFG FILE\n" "FROM THE EMULATIONSTATION RESOURCES DIRECTORY,\n" @@ -373,7 +373,7 @@ returnCode loadSystemConfigFile(std::string& errorMsg) if (SystemData::sSystemVector.size() == 0) { LOG(LogError) << "No systems found, does at least one system have a game present? " - "(Check that the file extensions are supported.)"; + "(Check that the file extensions are supported)"; errorMsg = "THE SYSTEMS CONFIGURATION FILE EXISTS, BUT NO\n" "GAME FILES WERE FOUND. EITHER PLACE YOUR GAMES\n" "IN THE CURRENTLY CONFIGURED ROM DIRECTORY OR\n" @@ -462,7 +462,6 @@ int main(int argc, char* argv[]) PowerSaver::init(); ViewController::init(&window); CollectionSystemManager::init(&window); - MameNames::init(); window.pushGui(ViewController::get()); bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); @@ -470,7 +469,7 @@ int main(int argc, char* argv[]) SDL_Event event {}; if (!window.init()) { - LOG(LogError) << "Window failed to initialize."; + LOG(LogError) << "Window failed to initialize"; return 1; } @@ -478,6 +477,7 @@ int main(int argc, char* argv[]) if (event.type == SDL_QUIT) return 1; + MameNames::init(); if (splashScreen) { std::string progressText = "Loading..."; @@ -492,7 +492,7 @@ int main(int argc, char* argv[]) if (returnCodeValue) { // Something went terribly wrong. if (errorMsg == "") { - LOG(LogError) << "Unknown error occured while parsing system config file."; + LOG(LogError) << "Unknown error occured while parsing systems configuration file"; Renderer::deinit(); return 1; } @@ -686,7 +686,7 @@ int main(int argc, char* argv[]) processQuitMode(); - LOG(LogInfo) << "EmulationStation cleanly shutting down."; + LOG(LogInfo) << "EmulationStation cleanly shutting down"; #if defined(_WIN64) closeConsole(); diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 6fe69492a..d55de7c83 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -167,7 +167,7 @@ bool SystemView::input(InputConfig* config, Input input) if (input.value != 0) { if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r && SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) { - LOG(LogInfo) << " Reloading all"; + LOG(LogInfo) << "Reloading all"; ViewController::get()->reloadAll(); return true; } diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index 736bd29f7..f1c19705a 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -50,7 +50,7 @@ MameNames::MameNames() if (!Utils::FileSystem::exists(xmlpath)) return; - LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; + LOG(LogInfo) << "Parsing MAME names file \"" << xmlpath << "\"..."; pugi::xml_document doc; #if defined(_WIN64) @@ -61,7 +61,7 @@ MameNames::MameNames() #endif if (!result) { - LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " + LOG(LogError) << "Error parsing MAME names file \"" << xmlpath << "\": " << result.description(); return; } @@ -81,7 +81,7 @@ MameNames::MameNames() if (!Utils::FileSystem::exists(xmlpath)) return; - LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; + LOG(LogInfo) << "Parsing MAME BIOSes file \"" << xmlpath << "\"..."; #if defined(_WIN64) result = doc.load_file(Utils::String::stringToWideString(xmlpath).c_str()); @@ -90,7 +90,7 @@ MameNames::MameNames() #endif if (!result) { - LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " + LOG(LogError) << "Error parsing MAME BIOSes file \"" << xmlpath << "\": " << result.description(); return; } @@ -107,7 +107,7 @@ MameNames::MameNames() if (!Utils::FileSystem::exists(xmlpath)) return; - LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; + LOG(LogInfo) << "Parsing MAME devices file \"" << xmlpath << "\"..."; #if defined(_WIN64) result = doc.load_file(Utils::String::stringToWideString(xmlpath).c_str()); @@ -116,7 +116,7 @@ MameNames::MameNames() #endif if (!result) { - LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " + LOG(LogError) << "Error parsing MAME devices file \"" << xmlpath << "\": " << result.description(); return; } diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index 117a0881e..e3530f653 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -35,16 +35,16 @@ std::shared_ptr Sound::getFromTheme(const std::shared_ptr& the const std::string& view, const std::string& element) { LOG(LogDebug) << "Sound::getFromTheme(): Looking for navigation sound tag ."; + element << "\">"; const ThemeData::ThemeElement* elem = theme->getElement(view, element, "sound"); if (!elem || !elem->has("path")) { - LOG(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file."; + LOG(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file"; return get(ResourceManager::getInstance()-> getResourcePath(":/sounds/" + element + ".wav")); } - LOG(LogDebug) << "Sound::getFromTheme(): Tag found, ready to load theme sound file."; + LOG(LogDebug) << "Sound::getFromTheme(): Tag found, ready to load theme sound file"; return get(elem->get("path")); } @@ -133,7 +133,7 @@ void Sound::init() // Convert buffer to stereo, 16bit, 44.1kHz. if (SDL_ConvertAudio(&cvt) < 0) { LOG(LogError) << "Error converting sound \"" << mPath << - "\" to 44.1kHz, 16bit, stereo format!\n" << " " << SDL_GetError(); + "\" to 44.1kHz, 16bit, stereo format: " << SDL_GetError(); delete[] cvt.buf; } else { diff --git a/es-core/src/resources/ResourceManager.cpp b/es-core/src/resources/ResourceManager.cpp index db2dcb909..73d42b61d 100644 --- a/es-core/src/resources/ResourceManager.cpp +++ b/es-core/src/resources/ResourceManager.cpp @@ -34,7 +34,8 @@ std::shared_ptr& ResourceManager::getInstance() return sInstance; } -std::string ResourceManager::getResourcePath(const std::string& path) const +std::string ResourceManager::getResourcePath(const std::string& path, + bool terminateOnFailure) const { // Check if this is a resource file. if ((path[0] == ':') && (path[1] == '/')) { @@ -72,22 +73,27 @@ std::string ResourceManager::getResourcePath(const std::string& path) const if (Utils::FileSystem::exists(testExePath)) { return testExePath; } - // For missing resources, log an error and terminate the application. This should - // indicate that we have a broken EmulationStation installation. + // indicate that we have a broken EmulationStation installation. If the argument + // terminateOnFailure is set to false though, then skip this step. else { - LOG(LogError) << "Program resource missing: " << path; - LOG(LogError) << "Tried to find the resource in the following locations:"; - LOG(LogError) << testHome; - #if defined(__APPLE__) - LOG(LogError) << applePackagePath; - #elif defined(__unix__) - LOG(LogError) << testDataPath; - #endif - LOG(LogError) << testExePath; - LOG(LogError) << "Has EmulationStation been properly installed?"; - Scripting::fireEvent("quit"); - emergencyShutdown(); + if (terminateOnFailure) { + LOG(LogError) << "Program resource missing: " << path; + LOG(LogError) << "Tried to find the resource in the following locations:"; + LOG(LogError) << testHome; + #if defined(__APPLE__) + LOG(LogError) << applePackagePath; + #elif defined(__unix__) + LOG(LogError) << testDataPath; + #endif + LOG(LogError) << testExePath; + LOG(LogError) << "Has EmulationStation been properly installed?"; + Scripting::fireEvent("quit"); + emergencyShutdown(); + } + else { + return ""; + } } } diff --git a/es-core/src/resources/ResourceManager.h b/es-core/src/resources/ResourceManager.h index a18f29454..76e2259a5 100644 --- a/es-core/src/resources/ResourceManager.h +++ b/es-core/src/resources/ResourceManager.h @@ -41,7 +41,7 @@ public: void unloadAll(); void reloadAll(); - std::string getResourcePath(const std::string& path) const; + std::string getResourcePath(const std::string& path, bool terminateOnFailure = true) const; const ResourceData getFileData(const std::string& path) const; bool fileExists(const std::string& path) const; diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index f168a6b3d..d0915d4fb 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -566,7 +566,7 @@ namespace Utils if (!_overwrite && exists(_destination_path)) { LOG(LogError) << "Destination file exists and the overwrite flag " - "has not been set."; + "has not been set"; return true; } @@ -578,8 +578,8 @@ namespace Utils #endif if (sourceFile.fail()) { - LOG(LogError) << "Couldn't read from source file (" << _source_path << - "), permission problems?"; + LOG(LogError) << "Couldn't read from source file \"" << _source_path << + "\", permission problems?"; sourceFile.close(); return true; } @@ -592,8 +592,8 @@ namespace Utils #endif if (targetFile.fail()) { - LOG(LogError) << "Couldn't write to target file (" << _destination_path << - "), permission problems?"; + LOG(LogError) << "Couldn't write to target file \"" << _destination_path << + "\", permission problems?"; targetFile.close(); return true; } @@ -624,7 +624,7 @@ namespace Utils if (!_overwrite && exists(_destination_path)) { LOG(LogError) << "Destination file exists and the overwrite flag " - "has not been set."; + "has not been set"; return true; }