| 8 | std::string getTmpDirPath() { return fs::temp_directory_path().string(); } |
| 9 | |
| 10 | std::string getUniqueFilePath(std::string Dir, std::string Name, |
| 11 | std::string Ext) { |
| 12 | unsigned Counter = 0; |
| 13 | fs::path Result = fs::path(Dir) / fs::path(Name); |
| 14 | if (!Ext.empty()) |
| 15 | Result += "." + Ext; |
| 16 | |
| 17 | while (fs::exists(Result)) { |
| 18 | Result = fs::path(Dir) / fs::path(Name + '-' + std::to_string(Counter++)); |
| 19 | if (!Ext.empty()) |
| 20 | Result += "." + Ext; |
| 21 | } |
| 22 | |
| 23 | return Result; |
| 24 | } |
| 25 | |
| 26 | } // namespace ftg |