mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
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:
parent
8286dec7f6
commit
72d997aa58
6 changed files with 262 additions and 100 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue