* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_utility
*/
+#include "gmxpre.h"
+
#include "path.h"
+#include "config.h"
+
#include <cctype>
#include <cerrno>
#include <cstdlib>
#include <algorithm>
-#include "config.h"
-
#include <sys/stat.h>
+
#ifdef GMX_NATIVE_WINDOWS
#include <direct.h>
#else
return path.substr(pos+1);
}
+std::string Path::stripExtension(const std::string &path)
+{
+ size_t dirSeparatorPos = path.find_last_of(cDirSeparators);
+ size_t extPos = path.find_last_of('.');
+ if (extPos == std::string::npos
+ || (dirSeparatorPos != std::string::npos && extPos < dirSeparatorPos))
+ {
+ return path;
+ }
+ return path.substr(0, extPos);
+}
+
std::string Path::normalize(const std::string &path)
{
std::string result(path);