mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 15:10:38 +00:00
[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:
parent
983a696e3f
commit
8ab9f1a345
1 changed files with 15 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue