| 326 | } |
| 327 | |
| 328 | std::string GenerateUniqueFileName(std::string const & path, std::string name, std::string_view ext) |
| 329 | { |
| 330 | // Remove extension, if file name already contains it. |
| 331 | if (name.ends_with(ext)) |
| 332 | name.resize(name.size() - ext.size()); |
| 333 | |
| 334 | size_t counter = 1; |
| 335 | std::string suffix, res; |
| 336 | do |
| 337 | { |
| 338 | res = name; |
| 339 | res = base::JoinPath(path, res.append(suffix).append(ext)); |
| 340 | if (!Platform::IsFileExistsByFullPath(res)) |
| 341 | break; |
| 342 | suffix = strings::to_string(counter++); |
| 343 | } |
| 344 | while (true); |
| 345 | |
| 346 | return res; |
| 347 | } |
| 348 | |
| 349 | std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) |
| 350 | { |