MCPcopy Create free account
hub / github.com/ablab/spades / createUniquePath

Function createUniquePath

ext/src/llvm/Path.cpp:740–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738}
739
740void createUniquePath(const Twine &Model, SmallVectorImpl<char> &ResultPath,
741 bool MakeAbsolute) {
742 SmallString<128> ModelStorage;
743 Model.toVector(ModelStorage);
744
745 if (MakeAbsolute) {
746 // Make model absolute by prepending a temp directory if it's not already.
747 if (!sys::path::is_absolute(Twine(ModelStorage))) {
748 SmallString<128> TDir;
749 sys::path::system_temp_directory(true, TDir);
750 sys::path::append(TDir, Twine(ModelStorage));
751 ModelStorage.swap(TDir);
752 }
753 }
754
755 ResultPath = ModelStorage;
756 ResultPath.push_back(0);
757 ResultPath.pop_back();
758
759 // Replace '%' with random chars.
760 for (unsigned i = 0, e = ModelStorage.size(); i != e; ++i) {
761 if (ModelStorage[i] == '%')
762 ResultPath[i] = "0123456789abcdef"[sys::Process::GetRandomNumber() & 15];
763 }
764}
765
766std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
767 SmallVectorImpl<char> &ResultPath,

Callers 1

createUniqueEntityFunction · 0.85

Calls 8

is_absoluteFunction · 0.85
toVectorMethod · 0.80
appendFunction · 0.70
TwineClass · 0.50
swapMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected