Re: How to detect whether a filename points to a text clipping?
Re: How to detect whether a filename points to a text clipping?
- Subject: Re: How to detect whether a filename points to a text clipping?
- From: Nick Zitzmann <email@hidden>
- Date: Sun, 30 Mar 2003 07:35:12 -0800
On Saturday, March 29, 2003, at 11:57 PM, Alex wrote:
Is there any method of finding out whether a file name is pointing to
a text clipping?
I'd do
if ([[myFilePath pathExtension] isEqualToString:@"textClipping"]){
NSLog(@"do your magic on textClipping file");
} else {
NSLog(@"ignore, it's not a textClipping");
}
No, this will not work correctly because it's not reasonable to expect
that all text clippings will have the "textClipping" extension.
Here's some sample code that ought to work better. It's similar to (but
not the same as) some code I wrote for one of my applications,
DropPrint:
NSString *filename; // this contains the POSIX path to a file
NSDictionary *filenamesAttributes = [[NSFileManager defaultManager]
fileAttributesAtPath:filename traverseLink:YES];
if (([filenamesAttributes fileHFSTypeCode] == 'clpt' &&
[filenamesAttributes fileHFSCreatorCode] == 'MACS') || [[filename
pathExtension] isEqualToString:@"textClipping"] == YES)
{
// it's a text clipping if the code reaches this point
}
else
{
// it's not a text clipping
}
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://dreamless.home.attbi.com/
"Building the future and keeping the past alive are one and the same
thing." - Metal Gear Solid 2
_______________________________________________
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.