| 55 | } |
| 56 | |
| 57 | fs::path MakeTempDir(const std::string& name) { |
| 58 | #if defined(_WIN32) || defined(_WIN64) |
| 59 | const auto suffix = std::to_string(GetCurrentProcessId()); |
| 60 | #else |
| 61 | const auto suffix = std::to_string(getpid()); |
| 62 | #endif |
| 63 | fs::path dir = fs::temp_directory_path() / (name + "-" + suffix); |
| 64 | fs::remove_all(dir); |
| 65 | fs::create_directories(dir); |
| 66 | return dir; |
| 67 | } |
| 68 | |
| 69 | void WriteFile(const fs::path& path, const std::string& content) { |
| 70 | std::ofstream ofs(path, std::ios::binary); |