* EOAccess/EOModel.m

add -_writePlist:toFile:
use it in -writeToFile:
this makes writing OPENSTEP plists work on OSX!



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30842 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
dwetzel 2010-06-24 05:40:42 +00:00
parent aef2be1753
commit cf46680fa1
2 changed files with 40 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2010-06-23 David Wetzel <dave@turbocat.de>
* EOAccess/EOModel.m
add -_writePlist:toFile:
use it in -writeToFile:
this makes writing OPENSTEP plists work on OSX!
2010-06-14 David Wetzel <dave@turbocat.de>
* EOAccess/EODatabaseContext.m
recordUpdateForObject: changes:

View file

@ -539,6 +539,36 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
return self;
}
- (BOOL) _writePlist:(NSDictionary*)plist toFile:(NSString*) path
{
NSData * fileData;
NSString * errorDescription = nil;
NSError * error = nil;
BOOL ok = NO;
// we should use
// NSPropertyListSerialization dataWithPropertyList:format:options:error:
// but that is not hacked to work on apple in Additions
fileData = [NSPropertyListSerialization dataFromPropertyList:plist
format:NSPropertyListOpenStepFormat
errorDescription:&errorDescription];
if (!fileData) {
NSLog(@"%s: Cannot convert plist to data.", __PRETTY_FUNCTION__);
return NO;
}
ok = [fileData writeToFile:path
options:NSAtomicWrite
error:&error];
if (!ok) {
NSLog(@"%s:%@", __PRETTY_FUNCTION__, error);
}
return ok;
}
/**
* <p>Writes the receivers plist representation into an
* .eomodeld file wrapper located at path. </p>
@ -634,7 +664,8 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
fileName = [path stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.plist",
[entityPList objectForKey: @"name"]]];
if ([entityPList writeToFile: fileName atomically: YES] == NO)
if ([self _writePlist:entityPList toFile:fileName] == NO)
{
NSString *fmt;
fmt = [NSString stringWithFormat: @"Could not create file: %@",
@ -653,7 +684,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
fileName = [stProcPList objectForKey: @"name"];
fileName = [fileName stringByAppendingPathExtension: @"storedProcedure"];
fileName = [path stringByAppendingPathComponent: fileName];
if ([stProcPList writeToFile: fileName atomically: YES] == NO)
if ([self _writePlist:stProcPList toFile:fileName] == NO)
{
NSString *fmt;
fmt = [NSString stringWithFormat: @"Could not create file: %@",
@ -674,7 +705,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
fileName = path;
}
if ([pList writeToFile: fileName atomically: YES] == NO)
if ([self _writePlist:pList toFile:fileName] == NO)
{
NSString *fmt;
fmt = [NSString stringWithFormat: @"Could not create file: %@",