This PR makes it easier in #20744 to remove our dependency on the boost::filesystem::unique_path()
function which does not have a direct equivalent in C++17.
This PR attempts to re-implement boost::filesystem::unique_path()
as GetUniquePath(path)
but the implementations are not meant to be the same.
Note:
-
Boost 1.75.0 implementation of
unique_path
: https://github.com/boostorg/filesystem/blob/9cab675b71e98706886a87afe7c19eb9da568961/src/unique_path.cpp#L235 -
In the previous implementation, I attempted to add:
0fs::path GetUniquePath(const fs::path& base) 1{ 2 FastRandomContext rnd; 3 fs::path tmpFile = base / HexStr(rnd.randbytes(8)); 4 return tmpFile; 5}
to
fs.cpp
but this leads to a circular dependency: “fs -> random -> logging -> fs”. That is why the modified implementation adds a new file.