diff --git a/src/ModFile.cc b/src/ModFile.cc index e11d5e15..1feca9ef 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -853,7 +853,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo macOS), if we directly remove the "+" subdirectory, then the preprocessor is not able to recreate it afterwards (presumably because MATLAB maintains some sort of lock on it). The workaround is to rename - it before deleting it. */ + it before deleting it (the renaming must occur in the same directory, + otherwise it may file if the destination is not on the same + filesystem). */ if (filesystem::exists("+" + basename)) { auto tmp = unique_path(); @@ -1582,7 +1584,7 @@ ModFile::unique_path() string rand_str(rand_length, '\0'); for (auto &dis : rand_str) dis = possible_characters[distribution(generator)]; - path = filesystem::temp_directory_path() / rand_str; + path = rand_str; } while (filesystem::exists(path)); diff --git a/src/ModFile.hh b/src/ModFile.hh index 5c3950d1..1bfe7cb7 100644 --- a/src/ModFile.hh +++ b/src/ModFile.hh @@ -131,7 +131,7 @@ private: void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const; void writeJsonFileHelper(const string &fname, ostringstream &output) const; vector pac_growth; - /* Generate a random temporary path. Equivalent to + /* Generate a random temporary path, in the current directory. Equivalent to boost::filesystem::unique_path(). Both are insecure, but currently there is no better portable solution. Maybe in a later C++ standard? */ static filesystem::path unique_path();