From 66996711ae69503e2b2d8800875d629fac9cfbe0 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 5 Jul 2004 16:39:02 +0000 Subject: [PATCH] Make sure that a directory name containing a '.' doesn't screw up the ::base() and ::extension() functions. --- simgear/misc/sg_path.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 ""; -- 2.39.5