return true;
}
else {
- SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB1" ), tr( "OK" ) );
- return false; // error opening library file for writing
+ // mkr : PAL8557
+ QString aFullPath = GetLibraryFileName();
+ QString aDir = aFullPath.left( aFullPath.findRev('/')+1 );
+ const int toCreateDir = SUIT_MessageBox::warn2( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ),
+ tr( "MSG_ERROR_LIB_DIR_NOT_EXIST_RECREATE" ).arg(aDir), tr( "BUT_YES" ), tr( "BUT_NO" ), 1, 0, 0 );
+ if ( toCreateDir ) { // user selected to create a new ./salome subdirectory in HOME directory
+
+ // create directory
+ QString aCommand = QString("mkdir ") + aDir;
+ int status = system( aCommand.latin1() );
+
+ if ( status == -1 || status == 217 ) {
+ SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_RECREATE_DIR" ).arg(aDir), tr( "OK" ) );
+ return false;
+ }
+
+ // create XML file
+ libFile.open( IO_WriteOnly | IO_Truncate );
+ QDomDocument doc( DOCTYPE ); // create a simple XML stub
+ doc.appendChild( doc.createElement( ROOT_ELEMENT ) ); // IMPORTANT: do not delete this root element
+ QTextStream stream( &libFile );
+ doc.save( stream, 0 );
+ libFile.close();
+ return true;
+ }
+ else // user chose not to create a new ./salome subdirectory in HOME directory
+ return false;
}
}
catch ( ... ) {
tr( "MSG_ERROR_LIB_IS_RECREATE" ), tr( "BUT_YES" ), tr( "BUT_NO" ), 1, 0, 0 );
if ( toRecreate ) { // user selected to recreate a bad XML file
libFile.close(); // in case it was opened by doc.setContent()
+
+ // remove old bad file
+ QString aCommand = QString("rm -f ") + libFile.name();
+ system( aCommand.latin1() );
+
if ( !createLibFile() )
return false; // error opening library file for writing. MB was already displayed
msgstr "Error creating a library file and opening for writing."
msgid "MSG_ERROR_LIB_IS_RECREATE"
-msgstr "Library file is corrupt (bad XML structure). Remove it and create a new one?"
+msgstr "Library file is corrupt (bad XML structure) or read-protected. Remove it and create a new one?"
+
+msgid "MSG_ERROR_LIB_DIR_NOT_EXIST_RECREATE"
+msgstr "%1 directory doesn't exist. Create it?"
+
+msgid "MSG_ERROR_LIB_RECREATE_DIR"
+msgstr "Can not create %1 directory."
msgid "MSG_ERROR_LIB_IO"
msgstr "Unknown I/O error occured creating new library file."
msgid "MSG_ERROR_LIB_WRITE"
-msgstr "Error writing library file!"
+msgstr "Error writing library file: file is write-protected!"
msgid "MSG_ERROR_LIB_NIL_NODE"
msgstr "Error: the node to be exported is NULL"