forked from organicmaps/organicmaps
Functions for create file path using native folder separator
This commit is contained in:
parent
38d4a3d7f6
commit
79daf33233
3 changed files with 52 additions and 1 deletions
|
@ -18,4 +18,44 @@ void GetNameFromFullPath(string & name)
|
|||
name = name.substr(i+1);
|
||||
}
|
||||
|
||||
string GetNativeSeparator()
|
||||
{
|
||||
#ifdef OMIM_OS_WINDOWS
|
||||
return "\\";
|
||||
#elif
|
||||
return "/";
|
||||
#endif;
|
||||
}
|
||||
|
||||
string JoinFoldersToPath(const string & folder, const string & file)
|
||||
{
|
||||
return folder + GetNativeSeparator() + file;
|
||||
}
|
||||
|
||||
string JoinFoldersToPath(const string & folder1, const string & folder2, const string & file)
|
||||
{
|
||||
string nativeSeparator = GetNativeSeparator();
|
||||
return folder1 + nativeSeparator + folder2 + nativeSeparator + file;
|
||||
}
|
||||
|
||||
string JoinFoldersToPath(const string & folder1, const string & folder2, const string & folder3, const string & file)
|
||||
{
|
||||
string nativeSeparator = GetNativeSeparator();
|
||||
return folder1 + nativeSeparator + folder2 + nativeSeparator + folder3 + nativeSeparator + file;
|
||||
}
|
||||
|
||||
string JoinFoldersToPath(const vector<string> & folders, const string & file)
|
||||
{
|
||||
if (folders.empty())
|
||||
return file;
|
||||
|
||||
string nativeSeparator = GetNativeSeparator();
|
||||
string result;
|
||||
for (size_t i = 0; i < folders.size(); ++i)
|
||||
result = result + folders[i] + nativeSeparator;
|
||||
|
||||
result += file;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../std/string.hpp"
|
||||
#include "../std/vector.hpp"
|
||||
|
||||
namespace my
|
||||
{
|
||||
|
@ -9,4 +10,13 @@ namespace my
|
|||
|
||||
/// Get file name from full path.
|
||||
void GetNameFromFullPath(string & name);
|
||||
|
||||
/// Get folder separator for specific platform
|
||||
string GetNativeSeparator();
|
||||
|
||||
/// Create full path from some folder using native folders separator
|
||||
string JoinFoldersToPath(const string & folder, const string & file);
|
||||
string JoinFoldersToPath(const string & folder1, const string & folder2, const string & file);
|
||||
string JoinFoldersToPath(const string & folder1, const string & folder2, const string & folder3, const string & file);
|
||||
string JoinFoldersToPath(const vector<string> & folders, const string & file);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "defines.hpp"
|
||||
#include "../coding/file_name_utils.hpp"
|
||||
#include "../base/macros.hpp"
|
||||
#include "../base/logging.hpp"
|
||||
#include "../std/string.hpp"
|
||||
|
@ -34,7 +35,7 @@ namespace graphics
|
|||
|
||||
string const resourcePath(string const & name, EDensity d)
|
||||
{
|
||||
return string("resources-") + convert(d) + "/" + name;
|
||||
return my::JoinFoldersToPath(string("resources-") + convert(d), name);
|
||||
}
|
||||
|
||||
double visualScale(EDensity density)
|
||||
|
|
Loading…
Add table
Reference in a new issue