| 738 | } |
| 739 | |
| 740 | void 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 | |
| 766 | std::error_code createUniqueFile(const Twine &Model, int &ResultFd, |
| 767 | SmallVectorImpl<char> &ResultPath, |
no test coverage detected