MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / GenerateUniqueFileName

Method GenerateUniqueFileName

rtpose_wrapper/src/gtest/gtest-all.cpp:7706–7715  ·  view source on GitHub ↗

Returns a pathname for a file that does not currently exist. The pathname will be directory/base_name.extension or directory/base_name_ .extension if directory/base_name.extension already exists. The number will be incremented until a pathname is found that does not already exist. Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. There could be a race condition if two or more processes

Source from the content-addressed store, hash-verified

7704// There could be a race condition if two or more processes are calling this
7705// function at the same time -- they could both pick the same filename.
7706FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
7707 const FilePath& base_name,
7708 const char* extension) {
7709 FilePath full_pathname;
7710 int number = 0;
7711 do {
7712 full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
7713 } while (full_pathname.FileOrDirectoryExists());
7714 return full_pathname;
7715}
7716
7717// Returns true if FilePath ends with a path separator, which indicates that
7718// it is intended to represent a directory. Returns false otherwise.

Callers

nothing calls this directly

Calls 2

SetMethod · 0.80
FileOrDirectoryExistsMethod · 0.80

Tested by

no test coverage detected