diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-18 15:31:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-18 15:31:02 +0300 |
commit | 4bfeee3b4b6c2f58c0231fd5fe7e4c7c6042dc91 (patch) | |
tree | 0708b58a04f841fef5bade291140fc72dc2fff0c | |
parent | 7e0dd590a8f34f4e5e6bbb58b5376fd81ff494f0 (diff) | |
download | plus-4bfeee3b4b6c2f58c0231fd5fe7e4c7c6042dc91.tar.gz plus-4bfeee3b4b6c2f58c0231fd5fe7e4c7c6042dc91.tar.bz2 plus-4bfeee3b4b6c2f58c0231fd5fe7e4c7c6042dc91.tar.xz plus-4bfeee3b4b6c2f58c0231fd5fe7e4c7c6042dc91.zip |
improve paths file.
-rw-r--r-- | src/utils/paths.cpp | 12 | ||||
-rw-r--r-- | src/utils/paths.h | 4 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index 83c72c3d7..c7542829f 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -45,7 +45,6 @@ std::string getRealPath(const std::string &str) { - std::string path; #if defined(__OpenBSD__) || defined(__ANDROID__) char *realPath = reinterpret_cast<char*>(calloc(PATH_MAX, sizeof(char))); realpath(str.c_str(), realPath); @@ -55,18 +54,17 @@ std::string getRealPath(const std::string &str) if (!realPath) return ""; - path = realPath; + std::string path = realPath; free(realPath); return path; } bool isRealPath(const std::string &str) { - std::string path = getRealPath(str); - return str == path; + return str == getRealPath(str); } -bool checkPath(std::string path) +bool checkPath(const std::string &path) { if (path.empty()) return true; @@ -84,7 +82,7 @@ std::string &fixDirSeparators(std::string &str) return replaceAll(str, "/", "\\"); } -std::string removeLast(std::string str) +std::string removeLast(const std::string &str) { size_t pos2 = str.rfind("/"); const size_t pos3 = str.rfind("\\"); @@ -157,7 +155,7 @@ std::string getDesktopDir() file = std::string(xdg).append("/user-dirs.dirs"); } - StringVect arr = ResourceManager::loadTextFileLocal(file); + const StringVect arr = ResourceManager::loadTextFileLocal(file); FOR_EACH (StringVectCIter, it, arr) { std::string str = *it; diff --git a/src/utils/paths.h b/src/utils/paths.h index b9cdcca3c..0c36b2f66 100644 --- a/src/utils/paths.h +++ b/src/utils/paths.h @@ -29,11 +29,11 @@ std::string getRealPath(const std::string &str) A_WARN_UNUSED; bool isRealPath(const std::string &str) A_WARN_UNUSED; -bool checkPath(std::string path) A_WARN_UNUSED; +bool checkPath(const std::string &path) A_WARN_UNUSED; std::string &fixDirSeparators(std::string &str); -std::string removeLast(std::string str) A_WARN_UNUSED; +std::string removeLast(const std::string &str) A_WARN_UNUSED; std::string getSelfName() A_WARN_UNUSED; |