MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CreateUniqueFileName

Method CreateUniqueFileName

tensorflow/core/platform/env.cc:367–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367bool 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
390Thread::~Thread() {}
391

Callers 2

addToCacheMethod · 0.80
TEST_FFunction · 0.80

Calls 8

PrintfFunction · 0.85
c_strMethod · 0.80
NowMicrosFunction · 0.50
HostnameFunction · 0.50
FileExistsFunction · 0.50
emptyMethod · 0.45
okMethod · 0.45
clearMethod · 0.45

Tested by 1

TEST_FFunction · 0.64