Salome HOME
updated copyright message
[plugins/hybridplugin.git] / src / HYBRIDPlugin / HYBRIDPlugin_HYBRID.cxx
index 26f186de2786238529efdaa02b08d67ddb8e63fd..f9362f059c87232d2edcc8ae04909f29cfe1799f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2022  CEA/DEN, EDF R&D
+// Copyright (C) 2007-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
@@ -70,6 +70,9 @@
 #include <Basics_Utils.hxx>
 #include <utilities.h>
 
+#include <boost/filesystem.hpp>
+namespace boofs = boost::filesystem;
+
 #include <fstream>
 #include <algorithm>
 
@@ -96,6 +99,13 @@ static void removeFile( const std::string& fileName )
   }
 }
 
+// change results files permissions to user only (using boost to be used without C++17)
+static void chmodUserOnly(const char* filename)
+{
+  if (boofs::exists(filename))
+    boofs::permissions(filename, boofs::remove_perms | boofs::group_all | boofs::others_all );
+}
+
 //=============================================================================
 /*!
  *  
@@ -1383,11 +1393,17 @@ static bool writeGMFFile(MG_HYBRID_API*                                  MGInput
   }
 
   MGInput->GmfCloseMesh(idx);
+  chmodUserOnly(theMeshFileName);
   if (idxRequired)
-    MGInput->GmfCloseMesh(idxRequired);
+    {
+      MGInput->GmfCloseMesh(idxRequired);
+      chmodUserOnly(theRequiredFileName);
+    }
   if (idxSol)
-    MGInput->GmfCloseMesh(idxSol);
-  
+    {
+      MGInput->GmfCloseMesh(idxSol);
+      chmodUserOnly(theSolFileName);
+    }
   return true;
   
 }
@@ -1504,6 +1520,7 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh&         theMesh,
   }
 
   aIdsFile.close();
+  chmodUserOnly(aSmdsToHybridIdMapFileName.c_str());
 
   if ( ! Ok ) {
     if ( !_keepFiles ) {
@@ -1546,9 +1563,17 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh&         theMesh,
 
   if ( _logInStandardOutput && mgHybrid.IsLibrary() )
     std::cout << std::endl << mgHybrid.GetLog() << std::endl;
+  else
+    chmodUserOnly(aLogFileName.c_str());
   if ( Ok )
     std::cout << "End of Hybrid execution !" << std::endl;
 
+  if ( mgHybrid.IsExecutable() )
+    {
+      chmodUserOnly(aResultFileName.c_str());
+      chmodUserOnly(aResSolFileName.c_str());
+    }
+
   // --------------
   // read a result
   // --------------
@@ -1745,9 +1770,17 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh&         theMesh,
 
   if ( _logInStandardOutput && mgHybrid.IsLibrary() )
     std::cout << std::endl << mgHybrid.GetLog() << std::endl;
+  else
+    chmodUserOnly(aLogFileName.c_str());
   if ( Ok )
     std::cout << "End of Hybrid execution !" << std::endl;
 
+  if (mgHybrid.IsExecutable())
+    {
+      chmodUserOnly(aResultFileName.c_str());
+      chmodUserOnly(aResSolFileName.c_str());
+    }
+
   // --------------
   // read a result
   // --------------