NSUserDefaults fix for read-only filesystem. Comment type fixes in GSXML.m

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19034 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-04-06 06:27:32 +00:00
parent d503bb8c78
commit 61acb585bb
3 changed files with 36 additions and 10 deletions

View file

@ -737,6 +737,8 @@ static NSString *pathForUser(NSString *user)
return [self initWithContentsOfFile: path];
}
BOOL read_only = NO;
/**
* <init />
* Initializes defaults for the specified path. Returns an object with
@ -768,6 +770,7 @@ static NSString *pathForUser(NSString *user)
{
NSWarnMLog(@"Path '%@' is not writable - making user defaults for '%@' "
@" read-only\n", path, _defaultsDatabase);
}
else if ([mgr fileExistsAtPath: path isDirectory: &flag] == NO && flag == NO)
{
@ -1441,14 +1444,31 @@ static BOOL isPlistObject(id o)
initWithContentsOfFile: _defaultsDatabase];
if (newDict == nil)
{
NSLog(@"Unable to load defaults from '%@'", _defaultsDatabase);
if (wasLocked == NO)
if (_fileLock == nil)
{
[_fileLock unlock];
isLocked = NO;
/*
* Running with no readable user defaults ... but we were
* initialised that way (possibly on a read-only filesystem)
* so we just continue as best we can.
*/
newDict = [[NSMutableDictionaryClass allocWithZone: [self zone]]
initWithCapacity: 4];
}
else
{
/*
* The defaults system has become unreadable singe we started...
* probably a severe error of some sort
*/
NSLog(@"Unable to load defaults from '%@'", _defaultsDatabase);
if (wasLocked == NO)
{
[_fileLock unlock];
isLocked = NO;
}
[_lock unlock];
return NO;
}
[_lock unlock];
return NO;
}
}