diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index f3867fa5dc..9a00c1677a 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -52,15 +52,15 @@ namespace { -std::string GetDataPathText() noexcept +char const * GetDataPathHelp() { - return std::string( - "Directory where the generated mwms are put into. Also used as the path for helper " - "functions, such as those that calculate statistics and regenerate sections. ") + - Platform::GetWorkingDirectory() + "/../../data'."; + static std::string const kHelp = + "Directory where the generated mwms are put into. Also used as the path for helper " + "functions, such as those that calculate statistics and regenerate sections. " + "Default: " + + Platform::GetCurrentWorkingDirectory() + "/../../data'."; + return kHelp.c_str(); } - -string const gDataPathText = GetDataPathText(); } // namespace // Coastlines. @@ -72,7 +72,7 @@ DEFINE_bool(emit_coasts, false, // Generator settings and paths. DEFINE_string(osm_file_name, "", "Input osm area file."); DEFINE_string(osm_file_type, "xml", "Input osm area file type [xml, o5m]."); -DEFINE_string(data_path, "", (gDataPathText.c_str())); +DEFINE_string(data_path, "", GetDataPathHelp()); DEFINE_string(user_resource_path, "", "User defined resource path for classificator.txt and etc."); DEFINE_string(intermediate_data_path, "", "Path to stored nodes, ways, relations."); DEFINE_string(output, "", "File name for process (without 'mwm' ext)."); diff --git a/platform/platform.hpp b/platform/platform.hpp index 22cd8ff594..edbf6dd9d5 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -121,7 +121,9 @@ public: /// @return true if we can create custom texture allocator in drape static bool IsCustomTextureAllocatorSupported(); - static string GetWorkingDirectory() noexcept; + /// @returns path to current working directory. + /// @note In case of an error returns an empty string. + static string GetCurrentWorkingDirectory() noexcept; /// @return always the same writable dir for current user with slash at the end string WritableDir() const { return m_writableDir; } /// Set writable dir — use for testing and linux stuff only diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp index de46bec318..923aae36b0 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -156,17 +156,17 @@ bool Platform::IsFileExistsByFullPath(string const & filePath) void Platform::DisableBackupForFile(string const & filePath) {} // static -string Platform::GetWorkingDirectory() noexcept -{ - char path[PATH_MAX]; - char const * const answer = getcwd(path, PATH_MAX); - if (answer == nullptr) - return {}; - return answer; -} +bool Platform::IsCustomTextureAllocatorSupported() { return true; } // static -bool Platform::IsCustomTextureAllocatorSupported() { return true; } +string Platform::GetCurrentWorkingDirectory() noexcept +{ + char path[PATH_MAX]; + char const * const dir = getcwd(path, PATH_MAX); + if (dir == nullptr) + return {}; + return dir; +} bool Platform::IsDirectoryEmpty(string const & directory) { diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index 4055f5ef41..1f14201014 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -99,13 +99,13 @@ bool Platform::IsFileExistsByFullPath(string const & filePath) void Platform::DisableBackupForFile(string const & filePath) {} // static -string Platform::GetWorkingDirectory() noexcept +string Platform::GetCurrentWorkingDirectory() noexcept { char path[PATH_MAX]; - char const * const answer = getcwd(path, PATH_MAX); - if (answer == nullptr) + char const * const dir = getcwd(path, PATH_MAX); + if (dir == nullptr) return {}; - return answer; + return dir; } // static