diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index 10c509cfde..f3867fa5dc 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -50,6 +50,19 @@ #include "3party/gflags/src/gflags/gflags.h" +namespace +{ +std::string GetDataPathText() noexcept +{ + 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'."; +} + +string const gDataPathText = GetDataPathText(); +} // namespace + // Coastlines. DEFINE_bool(make_coasts, false, "Create intermediate file with coasts data."); DEFINE_bool(fail_on_coasts, false, "Stop and exit with '255' code if some coastlines are not merged."); @@ -59,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, "", "Directory for mwm generation, 'path_to_exe/../../data' if empty."); +DEFINE_string(data_path, "", (gDataPathText.c_str())); 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 5af3932331..22cd8ff594 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -121,6 +121,7 @@ public: /// @return true if we can create custom texture allocator in drape static bool IsCustomTextureAllocatorSupported(); + static string GetWorkingDirectory() 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 5e3042d41c..de46bec318 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -155,6 +155,16 @@ bool Platform::IsFileExistsByFullPath(string const & filePath) //static 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; +} + // static bool Platform::IsCustomTextureAllocatorSupported() { return true; } diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index 97841fd875..4055f5ef41 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -98,6 +98,16 @@ bool Platform::IsFileExistsByFullPath(string const & filePath) //static 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; +} + // static Platform::EError Platform::RmDir(string const & dirName) {