Required Double Extensions in Save Panel
Required Double Extensions in Save Panel
- Subject: Required Double Extensions in Save Panel
- From: John Nairn <email@hidden>
- Date: Tue, 17 Sep 2002 12:52:07 -0600
I added an option in my program to archive a collection of scientific
results into a compressed file by writing a TaskWrapper to the Unix
command
tar -c -f filename -z -v file1 file2 file3 (etc.)
It is very slick and an example of the power of OS X and underlying
Unix tools. There is only one minor problem when saving the file with
Cocoa tools.
The logical (i.e. highly desired) choice for the filename to hold the
archive is something like "myname.tar.gz". In other words there is a
double extension - a tar ball followed by compression to a gz file. I
get the file name from the user with a save panel and make its required
extension "tar.gz" with code
// save results to archive fiile
- (IBAction)gzipMPMResults:(id)sender
{
NSSavePanel *pan=[NSSavePanel savePanel];
[pan setRequiredFileType:@"tar.gz"];
[pan setTitle:@"Archive MPM Results"];
[pan beginSheetForDirectory:nil file:nil
modalForWindow:[self window] modalDelegate:self
didEndSelector:@selector(archivePanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
The save panel starts out OK. As I type a name, it fills in the
".tar.gz" extension. But when I click OK, the automatically supplied
extension is rejected. For example, say I enter text to be
"Archive.tar.gz", there is an error message saying you entered file
with extension "gz" while the required extension is "tar.gz" and I am
given the options of:
Use both: which leads to "Archive.tar.gz.tar.gz"
Use tar.gz: which removes gz and attaches required extension to give
"Archive.tar.tar.gz"
Thus no option is what I should have. I guess the Cocoa required
extension option does not look for double extensions? Is there a way to
clean up this process. I want "tar.gz" to be a required extension and I
want to be able to enter it. In other words I would like the save panel
to enforce a double extension. For now I have to delete half the
extension, such as to make it "Archive.tar", and then click "Use
tar.gz" when the error message appears to get to my goal of
"Archive.tar.gz".
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page:
http://www.mse.utah.edu/~nairn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.