10 virtual const char*
what() const noexcept {
11 return "Cannot generate more paths";
16 auto iter = std::find(usedPaths.begin(), usedPaths.end(), expected);
17 if (iter == usedPaths.end()) {
18 usedPaths.insert(expected);
23 for (
Size i = 1; i < 999; ++i) {
27 ss << std::setw(3) << std::setfill(
'0') << i;
37 iter = std::find(iter, usedPaths.end(), path);
38 if (iter == usedPaths.end()) {
39 usedPaths.insert(path);
47 char RandomPathManager::chars[] =
"abcdefghijklmnopqrstuvwxyz0123456789";
52 for (
Size i = 0; i < 8; ++i) {
54 const Size index =
min(
Size(rng() * (
sizeof(chars) - 1)),
Size(
sizeof(chars) - 2));
58 if (!extension.empty()) {
uint32_t Size
Integral type used to index arrays (by default).
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
#define NAMESPACE_SPH_END
virtual const char * what() const noexcept
Object representing a path on a filesystem.
Path & replaceExtension(const std::string &newExtension)
Changes the extension of the file.
Path & removeExtension()
Removes the extension from the path.
std::string native() const
Returns the native version of the path.
bool empty() const
Checks if the path is empty.
Path extension() const
Returns the extension of the filename.
Path getPath(const std::string extension="")
Generates a new random path.
Path getPath(const Path &expected)
Generates a unique path, based on given input path.
bool pathExists(const Path &path)
Checks if a file or directory exists (or more precisely, if a file or directory is accessible).