diff --git a/ChangeLog b/ChangeLog index 8172898..8d32448 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-06-23 David Wetzel + * EOAccess/EOModel.m + add -_writePlist:toFile: + use it in -writeToFile: + this makes writing OPENSTEP plists work on OSX! + 2010-06-14 David Wetzel * EOAccess/EODatabaseContext.m recordUpdateForObject: changes: diff --git a/EOAccess/EOModel.m b/EOAccess/EOModel.m index 94ca74c..985640f 100644 --- a/EOAccess/EOModel.m +++ b/EOAccess/EOModel.m @@ -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; +} + /** *

Writes the receivers plist representation into an * .eomodeld file wrapper located at path.

@@ -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: %@",