Salome HOME
Get results from sub directories.
[tools/libbatch.git] / src / Core / Utils.cxx
index 15afb5feffb5eaee3ddc8091b0e28a2dcfaf03b2..cd3deb0455a59950ed2a0b0de7f51a2eee15206e 100644 (file)
@@ -83,6 +83,20 @@ bool Utils::isAbsolutePath(const string & path)
   return path[0] == '/';
 }
 
+std::string Utils::dirname(const std::string & path)
+{
+#ifdef WIN32
+  const char separator = '\\';
+#else
+  const char separator = '/';
+#endif
+  std::size_t found = path.rfind(separator);
+  if(found != std::string::npos)
+    return path.substr(0, found+1);
+  else
+    return std::string(".");
+}
+
 string Utils::createAndOpenTemporaryFile(const string & prefix, ofstream & outputStream)
 {
   if (outputStream.is_open())