diff --git a/platform/platform.cpp b/platform/platform.cpp index d1653cd48b..41b0951a5b 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -145,11 +145,24 @@ string Platform::ReadPathForFile(string const & file, string searchScope) const { switch (searchScope[i]) { - case 'w': fullPath = base::JoinPath(m_writableDir, file); break; - case 'r': fullPath = base::JoinPath(m_resourcesDir, file); break; - case 's': fullPath = base::JoinPath(m_settingsDir, file); break; - case 'f': fullPath = file; break; - default : CHECK(false, ("Unsupported searchScope:", searchScope)); break; + case 'w': + ASSERT(!m_writableDir.empty(), ()); + fullPath = base::JoinPath(m_writableDir, file); + break; + case 'r': + ASSERT(!m_resourcesDir.empty(), ()); + fullPath = base::JoinPath(m_resourcesDir, file); + break; + case 's': + ASSERT(!m_settingsDir.empty(), ()); + fullPath = base::JoinPath(m_settingsDir, file); + break; + case 'f': + fullPath = file; + break; + default : + CHECK(false, ("Unsupported searchScope:", searchScope)); + break; } if (IsFileExistsByFullPath(fullPath)) return fullPath; diff --git a/platform/platform.hpp b/platform/platform.hpp index c26699fbba..b4af4d0a00 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -7,6 +7,7 @@ #include "coding/reader.hpp" +#include "base/assert.hpp" #include "base/exception.hpp" #include "base/macros.hpp" #include "base/task_loop.hpp" @@ -130,7 +131,11 @@ public: /// @note In case of an error returns an empty std::string. static std::string GetCurrentWorkingDirectory() noexcept; /// @return always the same writable dir for current user with slash at the end - std::string const & WritableDir() const { return m_writableDir; } + std::string const & WritableDir() const + { + ASSERT(!m_writableDir.empty(), ()); + return m_writableDir; + } /// Set writable dir — use for testing and linux stuff only void SetWritableDirForTests(std::string const & path); /// @return full path to file in user's writable directory @@ -140,7 +145,11 @@ public: std::string searchScope = std::string()) const; /// @return resource dir (on some platforms it's differ from Writable dir) - std::string const & ResourcesDir() const { return m_resourcesDir; } + std::string const & ResourcesDir() const + { + ASSERT(!m_resourcesDir.empty(), ()); + return m_resourcesDir; + } /// @note! This function is used in generator_tool and unit tests. /// Client app should not replace default resource dir. void SetResourceDir(std::string const & path);