• 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: A mystery with NSFileManager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A mystery with NSFileManager


  • Subject: Re: A mystery with NSFileManager
  • From: email@hidden
  • Date: Sat, 23 Feb 2002 16:08:27 -0800

[Chris, bcc:ing you in case you have some input on this before I log a radar that will probably go to you :->]

In other words, the -fileExistsAtPath:isDirectory: call returns success, but the isDirectory flag is set to NO -- it claims /tmp is not a directory. Now, there's nothing wrong with /tmp on my machine; it's sitting right there, it conatins some spam files I've made over the past days, I have rwx access to it.

lrwxrwxr-t 1 root wheel 11 Feb 23 17:09 tmp -> private/tmp

It's a symbolic link.

Oh. Um... hmm. Well, I don't really understand this (why the trailing slash matters, mostly), but... thanks to all who replied. Sounds like I want to use -stringByResolvingSymlinksInPath before I start trying to use the path. Thanks for the help!

Nope. I let you all get away with this too easily. :-> I don't think this is the problem.
I went and read man 7 symlink and the NSFileManager doc. Here's some data:

-stringByResolvingSymlinksInPath on @"/tmp" gives me @"/tmp". It is documented as doing this, to wit: "If the name of the receiving path begins with /private, the stringByResolvingSymlinksInPath method strips off the /private designator, provided the result is the name of an existing file." This seems a bit odd, though, because it means that symbolic links to things like /tmp are not resolved.
-fileExistsAtPath:isDirectory: says "The method traverses final symbolic links." So it should not be fazed by /tmp being a link. However, I suspect it's being bitten by this "feature" of -stringByResolvingSymlinksInPath, and is returning the wrong value for isDirectory as a result.
I'm guessing that adding the trailing slash (@"/tmp/") fixes the problem because it gets around the underlying "feature" in -stringByResolvingSymlinksInPath.

Does this seem plausible to those who understand the file system better than I? Should I log a bug?
Thanks...

Ben Haller
Stick Software
_______________________________________________
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.

  • Follow-Ups:
    • Re: A mystery with NSFileManager
      • From: Chris Kane <email@hidden>
  • Prev by Date: Simple Save Preference Tutorial
  • Next by Date: Frameworks inside applications
  • Previous by thread: Re: A mystery with NSFileManager
  • Next by thread: Re: A mystery with NSFileManager
  • Index(es):
    • Date
    • Thread