MCPcopy Create free account
hub / github.com/comaps/comaps / GenerateUniqueFileName

Function GenerateUniqueFileName

libs/map/bookmark_helpers.cpp:328–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328std::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
349std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName)
350{

Calls 5

JoinPathFunction · 0.85
to_stringFunction · 0.85
resizeMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.68