[readFileContentsType:toFile:] and [writeFileContents:] now use file

wrappers to use the same format as the new methods.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6813 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2000-06-26 22:22:20 +00:00
parent 983a696e3f
commit 8ab9f1a345

View file

@ -542,11 +542,14 @@ static NSMapTable *mimeMap = NULL;
- (BOOL) writeFileContents: (NSString*)filename
{
NSFileWrapper *wrapper;
NSData *data;
NSString *type;
BOOL ok = NO;
data = [NSData dataWithContentsOfFile: filename];
wrapper = [[NSFileWrapper alloc] initWithPath: filename];
data = [wrapper serializedRepresentation];
RELEASE(wrapper);
type = NSCreateFileContentsPboardType([filename pathExtension]);
NS_DURING
{
@ -697,6 +700,7 @@ static NSMapTable *mimeMap = NULL;
toFile: (NSString*)filename
{
NSData *d;
NSFileWrapper *wrapper;
if (type == nil)
{
@ -704,12 +708,19 @@ static NSMapTable *mimeMap = NULL;
}
d = [self dataForType: type];
if (d == nil)
d = [self dataForType: NSFileContentsPboardType];
if ([d writeToFile: filename atomically: NO] == NO)
{
d = [self dataForType: NSFileContentsPboardType];
if (d == nil)
return nil;
}
wrapper = [[NSFileWrapper alloc] initWithSerializedRepresentation: d];
if ([wrapper writeToFile: filename atomically: NO updateFilenames: NO] == NO)
{
RELEASE(wrapper);
return nil;
}
RELEASE(wrapper);
return filename;
}