Skip to content
Snippets Groups Projects
Commit 7baee731 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix bug under MATLAB+Windows when "+" subdirectory is already present

Under MATLAB+Windows (but not under Octave nor under GNU/Linux or 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.
parent 86a08f54
Branches
No related tags found
No related merge requests found
......@@ -752,7 +752,17 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
if (hasModelChanged)
{
// Erase possible remnants of previous runs
boost::filesystem::remove_all("+" + basename);
/* Under MATLAB+Windows (but not under Octave nor under GNU/Linux or
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. */
if (boost::filesystem::exists("+" + basename))
{
auto tmp = boost::filesystem::unique_path();
boost::filesystem::rename("+" + basename, tmp);
boost::filesystem::remove_all(tmp);
}
boost::filesystem::remove_all(basename + "/model/src");
boost::filesystem::remove_all(basename + "/model/bytecode");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment