MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / GenerateUniqueFileName

Method GenerateUniqueFileName

tests/gtest/gtest-all.cc:9516–9525  ·  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

9514// There could be a race condition if two or more processes are calling this
9515// function at the same time -- they could both pick the same filename.
9516FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
9517 const FilePath& base_name,
9518 const char* extension) {
9519 FilePath full_pathname;
9520 int number = 0;
9521 do {
9522 full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
9523 } while (full_pathname.FileOrDirectoryExists());
9524 return full_pathname;
9525}
9526
9527// Returns true if FilePath ends with a path separator, which indicates that
9528// it is intended to represent a directory. Returns false otherwise.

Callers

nothing calls this directly

Calls 1

FileOrDirectoryExistsMethod · 0.80

Tested by

no test coverage detected