Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-01 17:33:32 +0300
committerJacques Lucke <jacques@blender.org>2020-09-01 17:33:32 +0300
commitfec522be6a0ffb895f169f305ace5eabc92855b8 (patch)
tree11e5e26e0b87b4de9d8f6ae03727f164bddabd2c /intern/mantaflow
parenta708cdabe6ddf6b5d65e491cce0018b36695f443 (diff)
Fix T79941: mantaflow cache doesn't work with ' character in path
The fix is to escape the `'` character as well. Reviewers: sebbas Differential Revision: https://developer.blender.org/D8773
Diffstat (limited to 'intern/mantaflow')
-rw-r--r--intern/mantaflow/intern/MANTA_main.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index 5997e819ccf..8d92d616e15 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1086,15 +1086,19 @@ string MANTA::parseScript(const string &setup_string, FluidModifierData *fmd)
}
/* Dirty hack: Needed to format paths from python code that is run via PyRun_SimpleString */
-static string escapeSlashes(string const &s)
+static string escapePath(string const &s)
{
string result = "";
- for (string::const_iterator i = s.begin(), end = s.end(); i != end; ++i) {
- unsigned char c = *i;
- if (c == '\\')
+ for (char c : s) {
+ if (c == '\\') {
result += "\\\\";
- else
+ }
+ else if (c == '\'') {
+ result += "\\\'";
+ }
+ else {
result += c;
+ }
}
return result;
}
@@ -1155,13 +1159,13 @@ bool MANTA::writeData(FluidModifierData *fmd, int framenr)
if (mUsingSmoke) {
ss.str("");
- ss << "smoke_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "smoke_save_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
}
if (mUsingLiquid) {
ss.str("");
- ss << "liquid_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "liquid_save_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
}
@@ -1183,7 +1187,7 @@ bool MANTA::writeNoise(FluidModifierData *fmd, int framenr)
if (mUsingSmoke && mUsingNoise) {
ss.str("");
- ss << "smoke_save_noise_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "smoke_save_noise_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
}
@@ -1256,7 +1260,7 @@ bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable)
if (mUsingSmoke) {
ss.str("");
- ss << "smoke_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "smoke_load_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
result &= runPythonString(pythonCommands);
@@ -1264,7 +1268,7 @@ bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable)
}
if (mUsingLiquid) {
ss.str("");
- ss << "liquid_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "liquid_load_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
result &= runPythonString(pythonCommands);
@@ -1298,7 +1302,7 @@ bool MANTA::readNoise(FluidModifierData *fmd, int framenr, bool resumable)
return false;
ss.str("");
- ss << "smoke_load_noise_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "smoke_load_noise_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
@@ -1326,14 +1330,14 @@ bool MANTA::readMesh(FluidModifierData *fmd, int framenr)
return false;
ss.str("");
- ss << "liquid_load_mesh_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "liquid_load_mesh_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << mesh_format << "')";
pythonCommands.push_back(ss.str());
if (mUsingMVel) {
ss.str("");
- ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapeSlashes(directory) << "', "
- << framenr << ", '" << volume_format << "')";
+ ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
+ << ", '" << volume_format << "')";
pythonCommands.push_back(ss.str());
}
@@ -1367,8 +1371,8 @@ bool MANTA::readParticles(FluidModifierData *fmd, int framenr, bool resumable)
return false;
ss.str("");
- ss << "liquid_load_particles_" << mCurrentID << "('" << escapeSlashes(directory) << "', "
- << framenr << ", '" << volume_format << "', " << resumable_cache << ")";
+ ss << "liquid_load_particles_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
+ << ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
return (mParticlesFromFile = runPythonString(pythonCommands));
@@ -1399,13 +1403,13 @@ bool MANTA::readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
if (sourceDomain) {
ss.str("");
- ss << "fluid_load_vel_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
+ ss << "fluid_load_vel_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
<< ", '" << volume_format << "')";
}
else {
ss.str("");
- ss << "fluid_load_guiding_" << mCurrentID << "('" << escapeSlashes(directory) << "', "
- << framenr << ", '" << volume_format << "')";
+ ss << "fluid_load_guiding_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
+ << ", '" << volume_format << "')";
}
pythonCommands.push_back(ss.str());
@@ -1439,7 +1443,7 @@ bool MANTA::bakeData(FluidModifierData *fmd, int framenr)
BLI_path_make_safe(cacheDirGuiding);
ss.str("");
- ss << "bake_fluid_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " << framenr
+ ss << "bake_fluid_data_" << mCurrentID << "('" << escapePath(cacheDirData) << "', " << framenr
<< ", '" << volume_format << "')";
pythonCommands.push_back(ss.str());
@@ -1465,7 +1469,7 @@ bool MANTA::bakeNoise(FluidModifierData *fmd, int framenr)
BLI_path_make_safe(cacheDirNoise);
ss.str("");
- ss << "bake_noise_" << mCurrentID << "('" << escapeSlashes(cacheDirNoise) << "', " << framenr
+ ss << "bake_noise_" << mCurrentID << "('" << escapePath(cacheDirNoise) << "', " << framenr
<< ", '" << volume_format << "')";
pythonCommands.push_back(ss.str());
@@ -1492,8 +1496,8 @@ bool MANTA::bakeMesh(FluidModifierData *fmd, int framenr)
BLI_path_make_safe(cacheDirMesh);
ss.str("");
- ss << "bake_mesh_" << mCurrentID << "('" << escapeSlashes(cacheDirMesh) << "', " << framenr
- << ", '" << volume_format << "', '" << mesh_format << "')";
+ ss << "bake_mesh_" << mCurrentID << "('" << escapePath(cacheDirMesh) << "', " << framenr << ", '"
+ << volume_format << "', '" << mesh_format << "')";
pythonCommands.push_back(ss.str());
return runPythonString(pythonCommands);
@@ -1522,7 +1526,7 @@ bool MANTA::bakeParticles(FluidModifierData *fmd, int framenr)
BLI_path_make_safe(cacheDirParticles);
ss.str("");
- ss << "bake_particles_" << mCurrentID << "('" << escapeSlashes(cacheDirParticles) << "', "
+ ss << "bake_particles_" << mCurrentID << "('" << escapePath(cacheDirParticles) << "', "
<< framenr << ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
@@ -1552,7 +1556,7 @@ bool MANTA::bakeGuiding(FluidModifierData *fmd, int framenr)
BLI_path_make_safe(cacheDirGuiding);
ss.str("");
- ss << "bake_guiding_" << mCurrentID << "('" << escapeSlashes(cacheDirGuiding) << "', " << framenr
+ ss << "bake_guiding_" << mCurrentID << "('" << escapePath(cacheDirGuiding) << "', " << framenr
<< ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());