summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/file/resourcefile.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/file/resourcefile.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 3920f69..4b4c935 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -265,51 +265,53 @@ bool ResourceFile::lock( const QString &fileName )
//US fn.replace( QRegExp("/"), "_" );
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
if (QFile::exists( lockName )) return false;
QString lockUniqueName;
lockUniqueName = fn + KApplication::randomString( 8 );
url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
// Create unique file
QFile file( mLockUniqueName );
file.open( IO_WriteOnly );
file.close();
// Create lock file
- int result = ::link( QFile::encodeName( mLockUniqueName ),
+ int result = 0;
+#ifndef _WIN32_
+ result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
-
+#endif
if ( result == 0 ) {
addressBook()->emitAddressBookLocked();
return true;
}
// TODO: check stat
return false;
}
void ResourceFile::unlock( const QString &fileName )
{
QString fn = fileName;
//US change the implementation how the lockfilename is getting created
//US fn.replace( QRegExp( "/" ), "_" );
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
//US QString lockName = fn + ".lock";
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
QFile::remove( lockName );
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
}