summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2001-09-13 15:27:54 (GMT)
committerKen Martin <ken.martin@kitware.com>2001-09-13 15:27:54 (GMT)
commite3178eed975fb4ddde5334fd0c0ccdccea68a99d (patch)
tree21a555f12a4c774a3845bbaabfda921cde0b11ef /Source
parent275b334f8be1bd06d807ac9a5c1cb4cb66d6e26c (diff)
downloadCMake-e3178eed975fb4ddde5334fd0c0ccdccea68a99d.zip
CMake-e3178eed975fb4ddde5334fd0c0ccdccea68a99d.tar.gz
CMake-e3178eed975fb4ddde5334fd0c0ccdccea68a99d.tar.bz2
added shortest ext function
Diffstat (limited to 'Source')
-rw-r--r--Source/cmSystemTools.cxx17
-rw-r--r--Source/cmSystemTools.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 4d9bf11..29d96ea 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1247,6 +1247,23 @@ std::string cmSystemTools::GetFilenameExtension(const std::string& filename)
}
}
+/**
+ * Return file extension of a full filename (dot included).
+ */
+std::string cmSystemTools::GetFilenameShortestExtension(const std::string& filename)
+{
+ std::string name = cmSystemTools::GetFilenameName(filename);
+ std::string::size_type dot_pos = name.rfind(".");
+ if(dot_pos != std::string::npos)
+ {
+ return name.substr(dot_pos);
+ }
+ else
+ {
+ return "";
+ }
+}
+
/**
* Return file name without extension of a full filename (i.e. without path).
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index c85a4ea..e50e425 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -242,6 +242,7 @@ public:
///! return file extension of a full filename (dot included).
static std::string GetFilenameExtension(const std::string&);
+ static std::string GetFilenameShortestExtension(const std::string&);
///! return file name without extension of a full filename.
static std::string GetFilenameNameWithoutExtension(const std::string&);