[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNUstep Code Freeze
From: |
Wolfgang Lux |
Subject: |
Re: GNUstep Code Freeze |
Date: |
Wed, 1 Feb 2012 10:52:30 +0100 |
Hi Fred,
> Hi Wolfgang,
>
> your proposal is definitely cleaner than the current code, which uses the
> extensions as the file type. The problem with this proposal is that it will
> break all document based applications that call these methods. I remember
> adding these methods to get TextEdit to compile, but there I also had to
> change the defined types to get this working. That was less work then
> changing the application to use the old file extension code. I would expect
> the same to be true for other Cocoa applications being ported over to GNUstep.
> I would rather leave the current code in there until we get a real
> implementation for it.
I understand that my proposed change could break existing code (which is the
reason why I didn't commit it :-). Still I dislike the mess up of file types
and extensions, which required me to implement a workaround once.
So here is a second proposal. As fallback for code running on Tiger, which
doesn't support the new NSWorkspace methods, I'm using the following
implementations for -filenameExtension:isValidForType: and
-preferredFilenameExtensionForType:. Maybe we could use them for GNUstep, too?
- (BOOL)filenameExtension:(NSString *)extension isValidForType:(NSString
*)typeName
{
NSDocumentController *documentController = [NSDocumentController
sharedDocumentController];
NSArray *extensions = [documentController fileExtensionsFromType:typeName];
return [extensions containsObject:extension];
}
- (NSString *)preferredFilenameExtensionForType:(NSString *)typeName
{
NSDocumentController *documentController = [NSDocumentController
sharedDocumentController];
NSArray *extensions = [documentController fileExtensionsFromType:typeName];
return [extensions count] > 0 ? [extensions objectAtIndex:0] : nil;
}
Unfortunately, I haven't used -typeOfFile:error: so I have no fallback
implementation for that yet but I could try implementing one later today.
Wolfgang