Tidied and improved logging for read from and write to file.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-10-04 09:08:09 +00:00
parent 8286dec7f6
commit 72d997aa58
6 changed files with 262 additions and 100 deletions

View file

@ -470,24 +470,21 @@ static SEL appSel;
* <p>If there is a failure to load the file for any reason, the receiver
* will be released and the method will return nil.
* </p>
* <p>Works by invoking [NSString-initWithContentsOfFile:] and
* [NSString-propertyList] then checking that the result is a dictionary.
* </p>
*/
- (id) initWithContentsOfFile: (NSString*)path
{
NSString *myString;
NSData *someData;
someData = [[NSData allocWithZone: NSDefaultMallocZone()]
initWithContentsOfFile: path];
if (someData == nil)
{
/* NSData should have already logged an error message */
RELEASE(self);
return nil;
}
myString = [[NSString allocWithZone: NSDefaultMallocZone()]
initWithData: someData encoding: NSUTF8StringEncoding];
RELEASE(someData);
if (myString)
initWithContentsOfFile: path];
if (myString == nil)
{
DESTROY(self);
}
else
{
id result;
@ -504,12 +501,15 @@ static SEL appSel;
if ([result isKindOfClass: NSDictionaryClass])
{
self = [self initWithDictionary: result];
return self;
}
else
{
NSWarnMLog(@"Contents of file '%@' does not contain a dictionary",
path);
DESTROY(self);
}
}
NSWarnMLog(@"Contents of file '%@' does not contain a dictionary", path);
RELEASE(self);
return nil;
return self;
}
/**