diff options
author | Lars Oppermann <lo@openoffice.org> | 2002-10-24 14:44:30 +0000 |
---|---|---|
committer | Lars Oppermann <lo@openoffice.org> | 2002-10-24 14:44:30 +0000 |
commit | 5c5db90f6822e8076916a529f5bd0456749c474f (patch) | |
tree | f656fc85e7295de325e797d443200c08a0cd26d5 /desktop | |
parent | 0614026fb8cf47d65263b949dc28bb5cf8851314 (diff) |
#104142# create file in constructor
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/lockfile.cxx | 31 | ||||
-rw-r--r-- | desktop/source/app/lockfile.hxx | 5 |
2 files changed, 23 insertions, 13 deletions
diff --git a/desktop/source/app/lockfile.cxx b/desktop/source/app/lockfile.cxx index 175845f7eb..199f87b506 100644 --- a/desktop/source/app/lockfile.cxx +++ b/desktop/source/app/lockfile.cxx @@ -2,9 +2,9 @@ * * $RCSfile: lockfile.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: lo $ $Date: 2002-09-30 15:24:07 $ + * last change: $Author: lo $ $Date: 2002-10-24 15:44:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,6 +92,7 @@ namespace desktop { Lockfile::Lockfile(void) :m_bRemove(sal_False) + ,m_bIsLocked(sal_False) { // build the file-url to use for the lock OUString aUserPath; @@ -113,19 +114,30 @@ namespace desktop { // generate date string char *tmpTime = ctime( &t ); - tmpTime[24] = 0x00; // buffer is always 26 chars, remove \n + tmpTime[24] = 0x00; // buffer is always 26 chars, remove '\n' m_aDate = OUString::createFromAscii( tmpTime ); + // try to create file + File aFile(m_aLockname); + if (aFile.open( OpenFlag_Create ) == File::E_EXIST) { + m_bIsLocked = sal_True; + } else { + // new lock created + aFile.close( ); + syncToFile( ); + m_bRemove = sal_True; + } } sal_Bool Lockfile::check( void ) { - File aFile(m_aLockname); - if (aFile.open( OpenFlag_Create ) == File::E_EXIST) { - // lock exists, ask user what to do + + if (m_bIsLocked) { + // lock existed, ask user what to do if (execWarning( ) == RET_YES) { - // remove file and create new + // remove file and create new File::remove( m_aLockname ); + File aFile(m_aLockname); aFile.open( OpenFlag_Create ); aFile.close( ); syncToFile( ); @@ -137,10 +149,7 @@ namespace desktop { return sal_False; } } else { - // new lock created - aFile.close( ); - syncToFile( ); - m_bRemove = sal_True; + // lock was created by us return sal_True; } } diff --git a/desktop/source/app/lockfile.hxx b/desktop/source/app/lockfile.hxx index 7760b12186..f70ad04940 100644 --- a/desktop/source/app/lockfile.hxx +++ b/desktop/source/app/lockfile.hxx @@ -2,9 +2,9 @@ * * $RCSfile: lockfile.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: rt $ $Date: 2002-10-04 10:32:20 $ + * last change: $Author: lo $ $Date: 2002-10-24 15:44:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,6 +103,7 @@ namespace desktop { OUString m_aLockname; // flag whether the d'tor should delete the lock sal_Bool m_bRemove; + sal_Bool m_bIsLocked; // ID OUString m_aId; OUString m_aDate; |