]> SALOME platform Git repositories - plugins/hybridplugin.git/commitdiff
Salome HOME
Change input and results files permissions to user only V9_11_0a1 V9_11_0a2 V9_11_0b1
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 27 Apr 2023 14:38:04 +0000 (16:38 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 27 Apr 2023 14:38:04 +0000 (16:38 +0200)
src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx

index 26f186de2786238529efdaa02b08d67ddb8e63fd..834e5128f29426e734894f6979b773ee2d080ae5 100644 (file)
@@ -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
   // --------------