From: jfa Date: Fri, 13 Jan 2006 15:32:55 +0000 (+0000) Subject: PAL11238: Crash in ExportMED. X-Git-Tag: T_Before_Join_BR-D5-38-2003~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2fe605b57bf549d9f19ec317067066b21899f13f;p=modules%2Fsmesh.git PAL11238: Crash in ExportMED. --- diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index daf37787f..c56c56918 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -1194,29 +1194,16 @@ static void PrepareForWriting (const char* file) THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM); } } else { - // nonexisting file - TCollection_AsciiString aDirName = aPath.TrekValue(aPath.TrekLength()); - aPath.UpTrek(); - aPath.SetName(aDirName); - aPath.SetExtension(""); - OSD_Directory aDir (aPath); - TCollection_AsciiString aFullDirName; - aPath.SystemName(aFullDirName); - if (aDir.Exists()) { - aFile.Reset(); - aFile.Build(OSD_WriteOnly, OSD_Protection()); - if (aFile.Failed()) { - TCollection_AsciiString msg ("You cannot write to directory "); - msg += aFullDirName + "."; - THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM); - } else { - aFile.Close(); - aFile.Remove(); - } - } else { - TCollection_AsciiString msg ("Directory "); - msg += aFullDirName + " does not exist."; + // nonexisting file; check if it can be created + aFile.Reset(); + aFile.Build(OSD_WriteOnly, OSD_Protection()); + if (aFile.Failed()) { + TCollection_AsciiString msg ("You cannot create the file "); + msg += aFullName + ". Check the directory existance and access rights."; THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM); + } else { + aFile.Close(); + aFile.Remove(); } } }