• 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: Best way to determine if a path is a directory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to determine if a path is a directory?


  • Subject: Re: Best way to determine if a path is a directory?
  • From: Robert Walker <email@hidden>
  • Date: Wed, 31 Jan 2007 16:22:28 -0500

fileExistsAtPath:isDirectory:
Returns a Boolean value that indicates whether a specified file exists.

- (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *) isDirectory

Parameters
path
The path of a file or directory. If path begins with a tilde (~), it must first be expanded with stringByExpandingTildeInPath, or this method will return NO.


isDirectory
Upon return, contains YES if path is a directory, otherwise contains NO. Pass NULL if you do not need this information.


Return Value
YES if there is a file or directory at path, otherwise NO.

Discussion
This method does not traverse final symbolic links.

If you need to further determine if path is a package, use the NSWorkspace method isFilePackageAtPath:.

-------------------------------------------------

I would say from the above description that the short answer is NO. You need to do two checks; one for isDirectory and another for isFilePackageAtPath.


On Jan 31, 2007, at 3:38 PM, Martin van-Eerde wrote:

Yes I realize that (As you can right click and view the contents) but I don't want to start copying files to a application...

My app can accept a selection of items dragged to it from the finder, I am iterating through the selection and discarding anything that is a file or package/application leaving me with directories that can be used as a copy destination.


Thanks Martin

On 31 Jan 2007, at 20:17, Nick Zitzmann wrote:


On Jan 31, 2007, at 12:59 PM, Martin van-Eerde wrote:

Is there a better way, it just seems strange that I need to do a second call to remove packages/applications...

Packages/applications are directories...

Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

-- Robert Walker email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Best way to determine if a path is a directory? (From: Martin van-Eerde <email@hidden>)
 >Re: Best way to determine if a path is a directory? (From: Nick Zitzmann <email@hidden>)
 >Re: Best way to determine if a path is a directory? (From: Martin van-Eerde <email@hidden>)

  • Prev by Date: Re: addObserver confusion [SOLVED]
  • Next by Date: Releasing WebView
  • Previous by thread: Re: Best way to determine if a path is a directory?
  • Next by thread: addObserver confusion
  • Index(es):
    • Date
    • Thread