Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-07-03 20:23:05 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:54:14 +0300
commitc966bfed30e064149cf8f9c6aa06d9281a5a5c21 (patch)
treed6b8bfc3fa7b822c16fd140f1c5461a39ea3f6ae /platform
parent7494c3f57668407158a8ef12282e66328553295f (diff)
[platform]
Replaced Platform::AddOptionalPath with Platform::SetResourceDir. Added Platform::TestsDataPathForFile to read test files (usually placed in resource directory) in unit tests.
Diffstat (limited to 'platform')
-rw-r--r--platform/platform.cpp9
-rw-r--r--platform/platform.hpp15
2 files changed, 12 insertions, 12 deletions
diff --git a/platform/platform.cpp b/platform/platform.cpp
index bfffb65a7c..78dcdbde9a 100644
--- a/platform/platform.cpp
+++ b/platform/platform.cpp
@@ -32,7 +32,7 @@ Platform::EError Platform::ErrnoToError()
string Platform::ReadPathForFile(string const & file, string searchScope) const
{
if (searchScope.empty())
- searchScope = "wrfo";
+ searchScope = "wrf";
string fullPath;
for (size_t i = 0; i < searchScope.size(); ++i)
@@ -42,7 +42,6 @@ string Platform::ReadPathForFile(string const & file, string searchScope) const
case 'w': fullPath = m_writableDir + file; break;
case 'r': fullPath = m_resourcesDir + file; break;
case 's': fullPath = m_settingsDir + file; break;
- case 'o': fullPath = m_optionalDir + file; break;
case 'f': fullPath = file; break;
default : CHECK(false, ("Unsupported searchScope:", searchScope)); break;
}
@@ -50,9 +49,9 @@ string Platform::ReadPathForFile(string const & file, string searchScope) const
return fullPath;
}
- string possiblePaths = m_writableDir + "\n" + m_resourcesDir + "\n" + m_settingsDir + "\n" + m_optionalDir;
-
- MYTHROW(FileAbsentException, ("File", file, "doesn't exist in the scope", searchScope, "Have been looking in:\n", possiblePaths));
+ string const possiblePaths = m_writableDir + "\n" + m_resourcesDir + "\n" + m_settingsDir;
+ MYTHROW(FileAbsentException, ("File", file, "doesn't exist in the scope", searchScope,
+ "Have been looking in:\n", possiblePaths));
}
string Platform::HashUniqueID(string const & s)
diff --git a/platform/platform.hpp b/platform/platform.hpp
index 98de3e437f..930f488bba 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -52,9 +52,6 @@ public:
protected:
/// Usually read-only directory for application resources
string m_resourcesDir;
- /// Optional resource search path
- string m_optionalDir;
-
/// Writable directory to store downloaded map data
/// @note on some systems it can point to external ejectable storage
string m_writableDir;
@@ -88,11 +85,9 @@ public:
static bool IsFileExistsByFullPath(string const & filePath);
- /// @return void
- void AddOptionalPath(string const & path) { m_optionalDir = path; }
/// @return always the same writable dir for current user with slash at the end
string WritableDir() const { return m_writableDir; }
- /// @return set writable dir — use for testing and linux stuff only
+ /// Set writable dir — use for testing and linux stuff only
void SetWritableDirForTests(string const & path) { m_writableDir = path; }
/// @return full path to file in user's writable directory
string WritablePathForFile(string const & file) const { return WritableDir() + file; }
@@ -104,6 +99,9 @@ public:
/// @return resource dir (on some platforms it's differ from Writable dir)
string ResourcesDir() const { return m_resourcesDir; }
+ /// @note! This function is used in generator_tool and unit tests.
+ /// Client app should not replace default resource dir.
+ void SetResourceDir(string const & path) { m_resourcesDir = path; }
/// Creates directory at filesystem
EError MkDir(string const & dirName) const;
@@ -118,6 +116,9 @@ public:
/// @return full path to file in the temporary directory
string TmpPathForFile(string const & file) const { return TmpDir() + file; }
+ /// @return full path to file where stored data for unit tests.
+ string TestsDataPathForFile(string const & file) const { return ReadPathForFile(file); }
+
/// @return path for directory in the persistent memory, can be the same
/// as WritableDir, but on some platforms it's different
string SettingsDir() const { return m_settingsDir; }
@@ -209,7 +210,7 @@ public:
string GetMemoryInfo() const;
static EConnectionType ConnectionStatus();
- static bool IsConnected() { return ConnectionStatus() != EConnectionType::CONNECTION_NONE; };
+ static bool IsConnected() { return ConnectionStatus() != EConnectionType::CONNECTION_NONE; }
private:
void GetSystemFontNames(FilesList & res) const;