MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / TemporaryPath

Method TemporaryPath

TestHelper/TemporaryPath.cpp:32–49  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

30{
31 //-------------------------------------------------------------------------
32 TemporaryPath::TemporaryPath(TemporaryPathOption temporaryPathOption)
33 {
34 auto now = std::chrono::system_clock::now().time_since_epoch();
35 auto seed = static_cast<unsigned int>(now.count());
36 std::default_random_engine generator(seed);
37 std::uniform_int_distribution<int> distribution;
38 auto temp_directory = fs::temp_directory_path();
39
40 do
41 {
42 path_ = fs::absolute(temp_directory / std::to_string(distribution(generator)));
43 } while (Tools::FileExists(path_));
44
45 if (temporaryPathOption == TemporaryPathOption::CreateAsFolder)
46 fs::create_directories(path_);
47 else if (temporaryPathOption == TemporaryPathOption::CreateAsFile)
48 CreateEmptyFile(path_);
49 }
50
51 //-------------------------------------------------------------------------
52 TemporaryPath::~TemporaryPath()

Callers

nothing calls this directly

Calls 2

FileExistsFunction · 0.85
CreateEmptyFileFunction · 0.85

Tested by

no test coverage detected