• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to detect whether a filename points to a text clipping?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >Re: How to detect whether a filename points to a text clipping? (From: Alex <email@hidden>)

  • Prev by Date: Re: Enable a NSMenuItem created programmatically
  • Next by Date: Re: [OT] Subversion
  • Previous by thread: Re: How to detect whether a filename points to a text clipping?
  • Next by thread: Re: Unarchiving Problem Solved
  • Index(es):
    • Date
    • Thread