-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop relying on byteme::temp_file_path for tests.
It's simple enough to write ourselves so there's no need to incur a dependency on byteme's semi-internal testing functions.
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef TEMP_FILE_PATH_H | ||
#define TEMP_FILE_PATH_H | ||
|
||
#include <filesystem> | ||
#include <random> | ||
#include <string> | ||
|
||
inline std::string temp_file_path(const std::string& prefix) { | ||
auto path = std::filesystem::temp_directory_path(); | ||
path.append(prefix); | ||
|
||
std::random_device rd; | ||
std::mt19937_64 rng(rd()); | ||
std::filesystem::path full; | ||
do { | ||
full = path; | ||
full += std::to_string(rng()); | ||
} while (std::filesystem::exists(full)); | ||
|
||
return full; | ||
} | ||
|
||
#endif |