X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUIT%2FSUIT_FileValidator.cxx;h=14be720932b71b191d40928da0b3a40876d2442f;hb=bad17fa10a9ee5177948f9494855cd49e5e7c958;hp=d2afda00ed9c4f00d25d96294bfa3d0698eb7726;hpb=1c889394b028b786898a995d38c07c8f3d564837;p=modules%2Fgui.git diff --git a/src/SUIT/SUIT_FileValidator.cxx b/src/SUIT/SUIT_FileValidator.cxx index d2afda00e..14be72093 100755 --- a/src/SUIT/SUIT_FileValidator.cxx +++ b/src/SUIT/SUIT_FileValidator.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : SUIT_FileValidator.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // @@ -60,13 +61,13 @@ bool SUIT_FileValidator::canOpen( const QString& fileName, bool checkPermission if ( !QFile::exists( fileName ) ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( fileName ) ); + QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( fileName ) ); return false; } if ( checkPermission && !QFileInfo( fileName ).isReadable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); + QObject::tr( "ERR_OPEN_PERMISSION_DENIED" ).arg( fileName ) ); return false; } return true; @@ -91,24 +92,29 @@ bool SUIT_FileValidator::canSave( const QString& fileName, bool checkPermission if ( QFile::exists( fileName ) ) { if ( parent() ) if ( SUIT_MessageBox::question( parent(), QObject::tr( "WRN_WARNING" ), - QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( fileName ), - SUIT_MessageBox::Yes | SUIT_MessageBox::No, - SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) - return false; + QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( fileName ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No, + SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) + return false; if ( checkPermission && !QFileInfo( fileName ).isWritable() ) { if ( parent() ) - SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); + SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); return false; } } else { QString dirName = SUIT_Tools::dir( fileName ); + if ( !QFile::exists( dirName ) ) { + SUIT_MessageBox::critical( parent(), QObject::tr( "WRN_WARNING" ), + QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); + return false; + } if ( checkPermission && !QFileInfo( dirName ).isWritable() ) { if ( parent() ) - SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); + SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) ); return false; } } @@ -132,19 +138,19 @@ bool SUIT_FileValidator::canReadDir( const QString& dirName, bool checkPermissio if ( !info.exists() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); + QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); return false; } if ( !info.isDir() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) ); + QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) ); return false; } if ( checkPermission && !info.isReadable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( dirName ) ); + QObject::tr( "ERR_DIR_READ_PERMISSION_DENIED" ).arg( dirName ) ); return false; } return true; @@ -167,19 +173,19 @@ bool SUIT_FileValidator::canWriteDir( const QString& dirName, bool checkPermissi if ( !info.exists() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); + QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) ); return false; } if ( !info.isDir() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) ); + QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) ); return false; } if ( checkPermission && !info.isWritable() ) { if ( parent() ) SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( dirName ) ); + QObject::tr( "ERR_DIR_WRITE_PERMISSION_DENIED" ).arg( dirName ) ); return false; } return true;