From: ehofman Date: Mon, 5 Jul 2004 16:39:02 +0000 (+0000) Subject: Make sure that a directory name containing a '.' doesn't screw up the ::base() and... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=66996711ae69503e2b2d8800875d629fac9cfbe0;p=simgear.git Make sure that a directory name containing a '.' doesn't screw up the ::base() and ::extension() functions. --- diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx index 7dc1cb7f..101cf290 100644 --- a/simgear/misc/sg_path.cxx +++ b/simgear/misc/sg_path.cxx @@ -154,7 +154,7 @@ string SGPath::dir() const { // get the base part of the path (everything but the extension.) string SGPath::base() const { int index = path.rfind("."); - if (index >= 0) { + if ((index >= 0) && (path.find("/", index) == string::npos)) { return path.substr(0, index); } else { return ""; @@ -162,9 +162,11 @@ string SGPath::base() const { } // get the extention (everything after the final ".") +// but make sure no "/" follows the "." character (otherwise it +// is has to be a directory name containing a "."). string SGPath::extension() const { int index = path.rfind("."); - if (index >= 0) { + if ((index >= 0) && (path.find("/", index) == string::npos)) { return path.substr(index + 1); } else { return "";