| 365 | } |
| 366 | |
| 367 | bool Env::CreateUniqueFileName(string* prefix, const string& suffix) { |
| 368 | int32 tid = GetCurrentThreadId(); |
| 369 | #ifdef PLATFORM_WINDOWS |
| 370 | int32 pid = static_cast<int32>(GetCurrentProcessId()); |
| 371 | #else |
| 372 | int32 pid = static_cast<int32>(getpid()); |
| 373 | #endif |
| 374 | uint64 now_microsec = NowMicros(); |
| 375 | |
| 376 | *prefix += strings::Printf("%s-%x-%d-%llx", port::Hostname().c_str(), tid, |
| 377 | pid, now_microsec); |
| 378 | |
| 379 | if (!suffix.empty()) { |
| 380 | *prefix += suffix; |
| 381 | } |
| 382 | if (FileExists(*prefix).ok()) { |
| 383 | prefix->clear(); |
| 384 | return false; |
| 385 | } else { |
| 386 | return true; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | Thread::~Thread() {} |
| 391 | |