]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sg_path.cxx
Update the code a bit more, add a function to retreive the last error string and...
[simgear.git] / simgear / misc / sg_path.cxx
index 7dc1cb7fb2219fd4737da1ae89b7acc307d0b4c9..54f7138dbcde9167cb979b3a93a74a769107c340 100644 (file)
@@ -3,7 +3,7 @@
 //
 // Written by Curtis L. Olson, started April 1999.
 //
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1999  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -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 "";