mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Tidied indentation.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3662 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
76865f335a
commit
2e823e5dc5
2 changed files with 51 additions and 36 deletions
|
@ -33,12 +33,12 @@
|
|||
|
||||
@implementation NSDistributedLock
|
||||
|
||||
+ (NSDistributedLock*)lockWithPath: (NSString*)aPath
|
||||
+ (NSDistributedLock*) lockWithPath: (NSString*)aPath
|
||||
{
|
||||
return [[[self alloc] initWithPath: aPath] autorelease];
|
||||
return [[[self alloc] initWithPath: aPath] autorelease];
|
||||
}
|
||||
|
||||
- (void)breakLock
|
||||
- (void) breakLock
|
||||
{
|
||||
NSFileManager *fileManager;
|
||||
|
||||
|
@ -51,14 +51,14 @@
|
|||
lockTime = nil;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
[lockPath release];
|
||||
[lockTime release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSDistributedLock*)initWithPath: (NSString*)aPath
|
||||
- (NSDistributedLock*) initWithPath: (NSString*)aPath
|
||||
{
|
||||
NSFileManager *fileManager;
|
||||
NSString *lockDir;
|
||||
|
@ -72,33 +72,33 @@
|
|||
if ([fileManager fileExistsAtPath: lockDir isDirectory: &isDirectory] == NO)
|
||||
{
|
||||
NSLog(@"part of the path to the lock file '%@' is missing\n", lockPath);
|
||||
[self dealloc];
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
if (isDirectory == NO)
|
||||
{
|
||||
NSLog(@"part of the path to the lock file '%@' is not a directory\n",
|
||||
lockPath);
|
||||
[self dealloc];
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
if ([fileManager isWritableFileAtPath: lockDir] == NO)
|
||||
{
|
||||
NSLog(@"parent directory of lock file '%@' is not writable\n", lockPath);
|
||||
[self dealloc];
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
if ([fileManager isExecutableFileAtPath: lockDir] == NO)
|
||||
{
|
||||
NSLog(@"parent directory of lock file '%@' is not accessible\n",
|
||||
lockPath);
|
||||
[self dealloc];
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSDate*)lockDate
|
||||
- (NSDate*) lockDate
|
||||
{
|
||||
NSFileManager *fileManager;
|
||||
NSDictionary *attributes;
|
||||
|
@ -108,7 +108,7 @@
|
|||
return [attributes objectForKey: NSFileModificationDate];
|
||||
}
|
||||
|
||||
- (BOOL)tryLock
|
||||
- (BOOL) tryLock
|
||||
{
|
||||
NSFileManager *fileManager;
|
||||
NSMutableDictionary *attributes;
|
||||
|
@ -145,7 +145,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)unlock
|
||||
- (void) unlock
|
||||
{
|
||||
NSFileManager *fileManager;
|
||||
NSDictionary *attributes;
|
||||
|
|
|
@ -621,36 +621,44 @@ static NSMutableString *processName = nil;
|
|||
return;
|
||||
}
|
||||
|
||||
- (BOOL)synchronize
|
||||
- (BOOL) synchronize
|
||||
{
|
||||
NSMutableDictionary *newDict = nil;
|
||||
|
||||
if (tickingTimer == nil)
|
||||
{
|
||||
[NSTimer scheduledTimerWithTimeInterval:30
|
||||
target:self
|
||||
selector:@selector(__timerTicked:)
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
tickingTimer = [NSTimer scheduledTimerWithTimeInterval: 30
|
||||
target: self
|
||||
selector: @selector(__timerTicked:)
|
||||
userInfo: nil
|
||||
repeats: NO];
|
||||
}
|
||||
|
||||
// Get file lock - break any lock that is more than five minute old.
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
if ([[defaultsDatabaseLock lockDate] timeIntervalSinceNow] < -300.0)
|
||||
{
|
||||
[defaultsDatabaseLock breakLock];
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
return NO;
|
||||
if ([[defaultsDatabaseLock lockDate] timeIntervalSinceNow] < -300.0)
|
||||
{
|
||||
[defaultsDatabaseLock breakLock];
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
return NO;
|
||||
|
||||
DESTROY(dictionaryRep);
|
||||
|
||||
// Read the persistent data from the stored database
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath: defaultsDatabase])
|
||||
newDict = [[NSMutableDictionary allocWithZone:[self zone]]
|
||||
initWithContentsOfFile:defaultsDatabase];
|
||||
{
|
||||
newDict = [[NSMutableDictionary allocWithZone: [self zone]]
|
||||
initWithContentsOfFile: defaultsDatabase];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Creating defaults database file %@", defaultsDatabase);
|
||||
|
@ -659,9 +667,11 @@ static NSMutableString *processName = nil;
|
|||
attributes: nil];
|
||||
}
|
||||
|
||||
if (!newDict)
|
||||
newDict = [[NSMutableDictionary allocWithZone:[self zone]]
|
||||
initWithCapacity:1];
|
||||
if (!newDict)
|
||||
{
|
||||
newDict = [[NSMutableDictionary allocWithZone: [self zone]]
|
||||
initWithCapacity: 1];
|
||||
}
|
||||
|
||||
if (changedDomains)
|
||||
{ // Synchronize both dictionaries
|
||||
|
@ -670,16 +680,20 @@ static NSMutableString *processName = nil;
|
|||
|
||||
while ((obj = [enumerator nextObject]))
|
||||
{
|
||||
dict = [persDomains objectForKey:obj];
|
||||
if (dict) // Domane was added or changet
|
||||
[newDict setObject:dict forKey:obj];
|
||||
dict = [persDomains objectForKey: obj];
|
||||
if (dict) // Domain was added or changet
|
||||
{
|
||||
[newDict setObject: dict forKey: obj];
|
||||
}
|
||||
else // Domain was removed
|
||||
[newDict removeObjectForKey:obj];
|
||||
{
|
||||
[newDict removeObjectForKey: obj];
|
||||
}
|
||||
}
|
||||
[persDomains release];
|
||||
persDomains = newDict;
|
||||
// Save the changes
|
||||
if (![persDomains writeToFile:defaultsDatabase atomically:YES])
|
||||
if (![persDomains writeToFile: defaultsDatabase atomically: YES])
|
||||
{
|
||||
[defaultsDatabaseLock unlock];
|
||||
return NO;
|
||||
|
@ -698,9 +712,10 @@ static NSMutableString *processName = nil;
|
|||
object: nil];
|
||||
}
|
||||
else
|
||||
[newDict release];
|
||||
{
|
||||
[newDict release];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue