From: vsr Date: Thu, 1 Oct 2009 11:29:34 +0000 (+0000) Subject: Issue 0020377: [windows] Problems with OSD_File Remove X-Git-Tag: V4_1_0_maintainance_FINAL~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=339afdf8036e15c9b0e3eb0e886e5281dfd4c54c;p=plugins%2Fghs3dplugin.git Issue 0020377: [windows] Problems with OSD_File Remove --- diff --git a/src/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin_GHS3D.cxx index d3b3d4d..881912b 100644 --- a/src/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin_GHS3D.cxx @@ -50,6 +50,7 @@ using namespace std; #include #include #include +#include #include #include #include @@ -91,6 +92,16 @@ extern "C" #define HOLE_ID -1 +static void removeFile( const TCollection_AsciiString& fileName ) +{ + try { + OSD_File( fileName ).Remove(); + } + catch ( Standard_ProgramError ) { + MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied"); + } +} + //============================================================================= /*! * @@ -1037,12 +1048,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( ! Ok ) { if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); + removeFile( aFacesFileName ); + removeFile( aPointsFileName ); } return error(COMPERR_BAD_INPUT_MESH); } - OSD_File( aResultFileName ).Remove(); // needed for boundary recovery module usage + removeFile( aResultFileName ); // needed for boundary recovery module usage // ----------------- // run ghs3d mesher @@ -1089,7 +1100,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( Ok ) { if ( !_keepFiles ) - OSD_File( aLogFileName ).Remove(); + removeFile( aLogFileName ); } else if ( OSD_File( aLogFileName ).Size() > 0 ) { @@ -1100,17 +1111,17 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, else { // the log file is empty - OSD_File( aLogFileName ).Remove(); + removeFile( aLogFileName ); INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); } if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); - OSD_File( aResultFileName ).Remove(); - OSD_File( aBadResFileName ).Remove(); - OSD_File( aBbResFileName ).Remove(); + removeFile( aFacesFileName ); + removeFile( aPointsFileName ); + removeFile( aResultFileName ); + removeFile( aBadResFileName ); + removeFile( aBbResFileName ); } cout << "<" << aResultFileName.ToCString() << "> GHS3D output file "; if ( !Ok ) @@ -1178,12 +1189,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( ! Ok ) { if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); + removeFile( aFacesFileName ); + removeFile( aPointsFileName ); } return error(COMPERR_BAD_INPUT_MESH); } - OSD_File( aResultFileName ).Remove(); // needed for boundary recovery module usage + removeFile( aResultFileName ); // needed for boundary recovery module usage // ----------------- // run ghs3d mesher @@ -1219,7 +1230,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( Ok ) { if ( !_keepFiles ) - OSD_File( aLogFileName ).Remove(); + removeFile( aLogFileName ); } else if ( OSD_File( aLogFileName ).Size() > 0 ) { @@ -1229,18 +1240,18 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } else { // the log file is empty - OSD_File( aLogFileName ).Remove(); + removeFile( aLogFileName ); INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); } if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); - OSD_File( aResultFileName ).Remove(); - OSD_File( aBadResFileName ).Remove(); - OSD_File( aBbResFileName ).Remove(); + removeFile( aFacesFileName ); + removeFile( aPointsFileName ); + removeFile( aResultFileName ); + removeFile( aBadResFileName ); + removeFile( aBbResFileName ); } return Ok;