FCT
载入中...
搜索中...
未找到
path.cpp
浏览该文件的文档.
1#include "path.h"
2namespace FCT
3{
4 std::string GetUniqueDirectoryName(const std::filesystem::path& baseDir, const std::string& baseName)
5 {
6 std::filesystem::path targetDir = baseDir / baseName;
7
8 if (!std::filesystem::exists(targetDir)) {
9 return baseName;
10 }
11
12 int counter = 1;
13 std::string uniqueName;
14 std::filesystem::path uniqueDir;
15
16 do {
17 uniqueName = baseName + "_" + std::to_string(counter);
18 uniqueDir = baseDir / uniqueName;
19 counter++;
20 } while (std::filesystem::exists(uniqueDir));
21
22 return uniqueName;
23 }
24 /*
25 std::string GetUniqueDirectoryName(const std::string& baseDir, const std::string& baseName)
26 {
27 return GetUniqueDirectoryName(std::filesystem::path(baseDir), baseName);
28 }*/
29}
std::string GetUniqueDirectoryName(const std::filesystem::path &baseDir, const std::string &baseName)
定义 path.cpp:4