From 80e1effccfe597015a3efc963dc0861f0dcba9da Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 22 Aug 2014 12:44:46 +1000 Subject: [PATCH] Added some debug output to get more info for #1464 (unnecessary download of addon icons). To be removed later. --- src/io/file_manager.cpp | 19 +++++++++++++++++++ src/io/file_manager.hpp | 9 +-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp index e4d0ff499..ec7d64e32 100644 --- a/src/io/file_manager.cpp +++ b/src/io/file_manager.cpp @@ -350,6 +350,25 @@ FileManager::~FileManager() m_file_system = NULL; } // ~FileManager +// ---------------------------------------------------------------------------- +/** Returns true if the specified file exists. + */ +bool FileManager::fileExists(const std::string& path) const +{ +#ifdef DEBUG + bool exists = m_file_system->existFile(path.c_str()); + if(exists) return true; + // Now the original file was not found. Test if replacing \ with / helps: + std::string s = StringUtils::replace(path, "\\", "/"); + exists = m_file_system->existFile(s.c_str()); + if(exists) + Log::warn("FileManager", "File '%s' does not exists, but '%s' does!", + path.c_str(), s.c_str()); + return exists; +#else + return m_file_system->existFile(path.c_str()); +#endif +} // fileExists //----------------------------------------------------------------------------- /** Adds paths to the list of stk root directories. * \param roots A ":" separated string of directories to add. diff --git a/src/io/file_manager.hpp b/src/io/file_manager.hpp index cc77a32e5..986f0df69 100644 --- a/src/io/file_manager.hpp +++ b/src/io/file_manager.hpp @@ -133,6 +133,7 @@ public: std::string searchMusic(const std::string& file_name) const; std::string searchTexture(const std::string& fname) const; std::string getUserConfigFile(const std::string& fname) const; + bool fileExists(const std::string& path) const; void listFiles (std::set& result, const std::string& dir, bool make_full_path=false) const; @@ -155,14 +156,6 @@ public: m_music_search_path.push_back(path); } // pushMusicSearchPath - // ------------------------------------------------------------------------ - /** Returns true if the specified file exists. - */ - bool fileExists(const std::string& path) const - { - return m_file_system->existFile(path.c_str()); - } // fileExists - }; // FileManager extern FileManager* file_manager;