From: Christophe Bourcier Date: Thu, 27 Apr 2023 12:43:52 +0000 (+0200) Subject: change input and results files permissions to user only X-Git-Tag: V9_11_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6f9a2e7abe8cb9fb9e7529681e677035c61ab0a6;p=plugins%2Fghs3dplugin.git change input and results files permissions to user only --- diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index 2a29956..6e0012c 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -79,6 +79,10 @@ #include #include +#include + +namespace boofs = boost::filesystem; + #ifdef _DEBUG_ //#define _MY_DEBUG_ #endif @@ -112,6 +116,12 @@ static std::string flagsToErrorStr( int anInvalidEnforcedFlags ) return str; } +// change results files permissions to user only (using boost to be used without C++17) +static void chmodUserOnly(const char* filename) +{ + boofs::permissions(filename, boofs::remove_perms | boofs::group_all | boofs::others_all ); +} + typedef const list TTriaList; static const char theDomainGroupNamePrefix[] = "Domain_"; @@ -1571,11 +1581,19 @@ static bool writeGMFFile(MG_Tetra_API* MGInput MGInput->GmfSetLin( idx, GmfRequiredTriangles, int( anElemSet.size()+enfID )); } + // close input files and change results files permissions to user only MGInput->GmfCloseMesh(idx); + chmodUserOnly(theMeshFileName); if (idxRequired) - MGInput->GmfCloseMesh(idxRequired); + { + MGInput->GmfCloseMesh(idxRequired); + chmodUserOnly(theRequiredFileName); + } if (idxSol) - MGInput->GmfCloseMesh(idxSol); + { + MGInput->GmfCloseMesh(idxSol); + chmodUserOnly(theRequiredFileName); + } return true; } @@ -1736,6 +1754,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } } aIdsFile.close(); + chmodUserOnly(aSmdsToGhs3dIdMapFileName.ToCString()); if ( ! Ok ) { if ( !_keepFiles ) { removeFile( aGMFFileName ); @@ -1786,6 +1805,14 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, BRIEF_INFOS("") } + // change results files permissions to user only + chmodUserOnly(aLogFileName.ToCString()); + if (Ok) + { + chmodUserOnly(aResultFileName.ToCString()); + chmodUserOnly(aResSolFileName.ToCString()); + } + // -------------- // read a result // --------------