forked from OSchip/llvm-project
parent
3f0fa19bc4
commit
58ed0c6c09
|
@ -366,14 +366,12 @@ error_code unique_file(const Twine &model, int &result_fd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace '%' with random chars. From here on, DO NOT modify model. It may be
|
// From here on, DO NOT modify model. It may be needed if the randomly chosen
|
||||||
// needed if the randomly chosen path already exists.
|
// path already exists.
|
||||||
SmallString<128> RandomPath = Model;
|
SmallString<128> RandomPath = Model;
|
||||||
|
|
||||||
retry_random_path:
|
retry_random_path:
|
||||||
// This is opened here instead of above to make it easier to track when to
|
// Replace '%' with random chars.
|
||||||
// close it. Collisions should be rare enough for the possible extra syscalls
|
|
||||||
// not to matter.
|
|
||||||
for (unsigned i = 0, e = Model.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Model.size(); i != e; ++i) {
|
||||||
if (Model[i] == '%')
|
if (Model[i] == '%')
|
||||||
RandomPath[i] = "0123456789abcdef"[sys::Process::GetRandomNumber() & 15];
|
RandomPath[i] = "0123456789abcdef"[sys::Process::GetRandomNumber() & 15];
|
||||||
|
|
Loading…
Reference in New Issue