mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-23 05:00:46 +00:00
* 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:
parent
aef2be1753
commit
cf46680fa1
2 changed files with 40 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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: %@",
|
||||
|
|
Loading…
Reference in a new issue