From 8ab9f1a345e75b96a21f495cdabdda6538d3d32b Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Mon, 26 Jun 2000 22:22:20 +0000 Subject: [PATCH] [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 --- Source/NSPasteboard.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/NSPasteboard.m b/Source/NSPasteboard.m index ecdfd657b..a873acc94 100644 --- a/Source/NSPasteboard.m +++ b/Source/NSPasteboard.m @@ -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; }