summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2002-07-15 13:45:47 (GMT)
committerBrad King <brad.king@kitware.com>2002-07-15 13:45:47 (GMT)
commitc5574e096beb6136eff364f1cc5d046e8abb9302 (patch)
tree4820424489a1ba6f8fded8c41e6f1675a5e65ca1 /Source
parent1e75dd121253b47c5d229936e80125e82bcd283e (diff)
downloadCMake-c5574e096beb6136eff364f1cc5d046e8abb9302.zip
CMake-c5574e096beb6136eff364f1cc5d046e8abb9302.tar.gz
CMake-c5574e096beb6136eff364f1cc5d046e8abb9302.tar.bz2
ENH: Added GetFilenameWithoutLastExtension.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmSystemTools.cxx21
-rw-r--r--Source/cmSystemTools.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 8a11240..e4e3d95 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1880,6 +1880,27 @@ std::string cmSystemTools::GetFilenameWithoutExtension(const std::string& filena
}
+/**
+ * Return file name without extension of a full filename (i.e. without path).
+ * Warning: it considers the last extension (for example: removes .gz
+ * from .tar.gz)
+ */
+std::string
+cmSystemTools::GetFilenameWithoutLastExtension(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(0, dot_pos);
+ }
+ else
+ {
+ return name;
+ }
+}
+
+
void cmSystemTools::Glob(const char *directory, const char *regexp,
std::vector<std::string>& files)
{
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index b7f8911..0ef9b6f 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -255,6 +255,9 @@ public:
///! return file name without extension of a full filename.
static std::string GetFilenameWithoutExtension(const std::string&);
+ ///! return file name without its last (shortest) extension.
+ static std::string GetFilenameWithoutLastExtension(const std::string&);
+
static long int ModifiedTime(const char* filename);
/**