Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Tools.cpp
index e642cc59f65fe7385ee73c179bcea2dad2e032bb..dc13d953ce878864c61fe80c6c5c6f3eef1fee1d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "GeomAlgoAPI_Tools.h"
@@ -46,6 +45,8 @@ std::string File_Tools::extension(const std::string& theFileName)
   TCollection_AsciiString aFileName(theFileName.c_str());
   OSD_Path aPath(aFileName);
   TCollection_AsciiString anExtension = aPath.Extension();
+  if (anExtension.Length() < 2)
+    return "";
   // TCollection_AsciiString are numbered from 1
   anExtension = anExtension.SubString(2, anExtension.Length());
   anExtension.UpperCase();
@@ -60,6 +61,14 @@ std::string File_Tools::name(const std::string& theFileName)
   return aPath.Name().ToCString();
 }
 
+std::string File_Tools::path(const std::string& theFileName)
+{
+  OSD_Path aPath (theFileName.c_str());
+  Standard_Integer aTrekLen =
+    int(theFileName.size()) - aPath.Extension().Length() - aPath.Name().Length();
+  return theFileName.substr(0, aTrekLen);
+}
+
 bool AlgoError::isAlgorithmFailed(const GeomMakeShapePtr& theAlgorithm,
                                   const std::string& theFeature,
                                   std::string& theError)
@@ -75,14 +84,14 @@ bool AlgoError::isAlgorithmFailed(const GeomMakeShapePtr& theAlgorithm,
   if (!theAlgorithm->shape() || theAlgorithm->shape()->isNull()) {
     theError = "Error: Resulting shape";
     if (!theFeature.empty())
-      theError += "of " + theFeature;
+      theError += " of " + theFeature;
     theError += " is Null.";
     return true;
   }
   if (!theAlgorithm->isValid()) {
     theError = "Error: Resulting shape";
     if (!theFeature.empty())
-      theError += "of " + theFeature;
+      theError += " of " + theFeature;
     theError += " is not valid.";
     return true;
   }