| 98 | return path_; |
| 99 | } |
| 100 | std::string TempFile::MakeRandomName() |
| 101 | { |
| 102 | UUID uuid; |
| 103 | if (UuidCreate(&uuid) == RPC_S_OK) { |
| 104 | return str::ToNarrow(win::GuidToString(uuid)); |
| 105 | } |
| 106 | |
| 107 | // Fallback: generate a pseudo-random GUID-like string. |
| 108 | static thread_local std::mt19937_64 rng{ std::random_device{}() }; |
| 109 | std::uniform_int_distribution<uint32_t> dist32; |
| 110 | std::uniform_int_distribution<uint16_t> dist16; |
| 111 | |
| 112 | return std::format( |
| 113 | "{{{:08x}-{:04x}-{:04x}-{:04x}-{:012x}}}", |
| 114 | dist32(rng), // 32 bits |
| 115 | dist16(rng), // 16 bits |
| 116 | (dist16(rng) & 0x0FFF) | 0x4000, // version 4 |
| 117 | (dist16(rng) & 0x3FFF) | 0x8000, // variant 1 |
| 118 | (static_cast<uint64_t>(dist32(rng)) << 32) | dist32(rng) // 48 bits from 64 |
| 119 | ); |
| 120 | } |
| 121 | bool TempFile::Empty() const |
| 122 | { |
| 123 | return path_.empty(); |
nothing calls this directly
no test coverage detected