Re: Is a unix path a child of a parent
Re: Is a unix path a child of a parent
- Subject: Re: Is a unix path a child of a parent
- From: Thomas Tempelmann <email@hidden>
- Date: Tue, 12 Mar 2013 09:51:37 +0100
> How do you determine if a unix path childPath has a parent parentPath? (Or the other way around).
> A simple string comparison seems too simplistic.
> What are the gotchas?
The gotcha is with symbolic links (symlinks). If you get two paths to
the same file passed, one might be using symlinks, so the paths look
different to you.
Therefore, you need to get the "true" path. I don't recall which
function does this, but I'd try the functions in CFURL or NSURL.
Next, once you have the true path, I think you may indeed compare
their path components, but make sure to compare them case sensitive in
case you're looking at a case-sensitive file system. Due to the fact
that you've just retrieve the true paths, their case should be
aligned, even if the user passed in a wrong case on a case-insensitive
file system.
So, that's the two gotchas you need to test against: symlinks and case.
Though, don't take my word for it yet. I hope someone else will either
confirm or correct my answer here.
--
Thomas Tempelmann, http://www.tempel.org/
Follow me on Twitter: http://twitter.com/#!/tempelorg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden