From: kan Date: Wed, 21 Dec 2011 16:28:59 +0000 (+0000) Subject: Fixed file locking on Linux X-Git-Tag: CTH_1_7_3~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3caeb999f82d91d60b5c10042668a3c6cc5bf4c;p=modules%2Fgui.git Fixed file locking on Linux --- diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index 3508c2021..eb42e2d33 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -252,21 +252,22 @@ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFil #ifndef WIN32 fName += ".fcntl"; + + if ( myBlocFcntl ) + fclose( myBlocFcntl ); myBlocFcntl = fopen( fName.toLatin1().constData(), "w" ); -#endif lockFcntl( QString() ); +#endif } +#ifndef WIN32 /* * Lock theLF or myBlockFcntl if empty * returns 0 on success */ int LightApp_Driver::lockFcntl( QString theLF ) { -#ifdef WIN32 - return 0; -#else if ( theLF.isEmpty() && !myBlocFcntl ) return -2; @@ -282,10 +283,8 @@ int LightApp_Driver::lockFcntl( QString theLF ) fLock.l_len = 0; fLock.l_start = 0; return fcntl( fileno( aFD ), F_SETLK, &fLock ); -#endif - } - +#endif /*! Remove files. First item in is a directory with slash at the end. @@ -326,6 +325,12 @@ void LightApp_Driver::RemoveFiles( const ListOfFiles& theFiles, const bool IsDir } aDir.Remove(); } + //if ( IsDirDeleted ) + //{ +// bool ok = Qtx::rmDir( QString( theFiles[0].c_str() ) ); + // std::cout<<"\n DEBUG: rmdir "< MapOfListOfFiles; diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 5a822a310..e12db29cf 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -27,6 +27,8 @@ #include #include #include + +#include #endif #include "SUIT_Study.h" @@ -537,20 +539,18 @@ void SUIT_Session::createBackupTimer() #ifndef WIN32 used += ".fcntl"; myBFileFcntl = fopen( used.toLatin1().constData(), "w" ); -#endif lockFcntl( QString() ); +#endif } } +#ifndef WIN32 /* * Lock theLF or myBFileFcntl if empty * returns 0 on success */ int SUIT_Session::lockFcntl( QString theLF ) { -#ifdef WIN32 - return 0; -#else if ( theLF.isEmpty() && !myBFileFcntl ) return -2; @@ -579,8 +579,14 @@ void SUIT_Session::onBTimer() QApplication::setOverrideCursor( Qt::WaitCursor ); // clear folder - Qtx::rmDir( myBFolder ); - QDir().mkdir( myBFolder ); + QDir tmpDir( myBFolder ); + QFileInfoList aFolders = tmpDir.entryInfoList( QDir::Dirs|QDir::NoDotAndDotDot ); + + QFileInfoList::const_iterator aFoldersIt = aFolders.constBegin(); + for ( ; aFoldersIt != aFolders.constEnd(); ++aFoldersIt ) + { + Qtx::rmDir( (*aFoldersIt).absoluteFilePath() ); + } // create backup QString aName; diff --git a/src/SUIT/SUIT_Session.h b/src/SUIT/SUIT_Session.h index c0df6792c..a9b4e9b48 100755 --- a/src/SUIT/SUIT_Session.h +++ b/src/SUIT/SUIT_Session.h @@ -99,7 +99,9 @@ private: void createBackupTimer(); void restoreBackup(); void removeTmpFiles(); +#ifndef WIN32 int lockFcntl( QString theLF ); +#endif private: typedef QList AppList;