Added two missing methods for file wrapper

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6808 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2000-06-26 19:56:33 +00:00
parent 61e4cccf02
commit a6fd9d725d
2 changed files with 47 additions and 0 deletions

View file

@ -31,6 +31,7 @@
#include <AppKit/NSPasteboard.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSWorkspace.h>
#include <AppKit/NSFileWrapper.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
@ -564,6 +565,36 @@ static NSMapTable *mimeMap = NULL;
return ok;
}
- (BOOL)writeFileWrapper:(NSFileWrapper *)wrapper
{
NSString *filename = [wrapper preferredFilename];
NSData *data;
NSString *type;
BOOL ok = NO;
if (filename == nil)
[NSException raise: NSInvalidArgumentException
format: @"Cannot put file on pastboard with no preferred filename"];
data = [wrapper serializedRepresentation];
type = NSCreateFileContentsPboardType([filename pathExtension]);
NS_DURING
{
ok = [target setData: data
forType: type
isFile: YES
oldCount: changeCount];
}
NS_HANDLER
{
ok = NO;
[NSException raise: NSPasteboardCommunicationException
format: @"%@", [localException reason]];
}
NS_ENDHANDLER
return ok;
}
/*
* Determining Types
*/
@ -672,6 +703,9 @@ static NSMapTable *mimeMap = NULL;
type = NSCreateFileContentsPboardType([filename pathExtension]);
}
d = [self dataForType: type];
if (d == nil)
d = [self dataForType: NSFileContentsPboardType];
if ([d writeToFile: filename atomically: NO] == NO)
{
return nil;
@ -679,6 +713,16 @@ static NSMapTable *mimeMap = NULL;
return filename;
}
- (NSFileWrapper *)readFileWrapper
{
NSData *d = [self dataForType: NSFileContentsPboardType];
if (d == nil)
return nil;
return AUTORELEASE([[NSFileWrapper alloc] initWithSerializedRepresentation: d]);
}
- (NSString*) stringForType: (NSString*)dataType
{
return [self propertyListForType: dataType];