The thing I'm trying to accomplish is to iterate all the files in a subtree, and then compute the last few parts of the path from that top-level directory.
I get the top-level directory by asking for the documents directory, and it gives me "/var/.../Documents/" (to which I append "Foo"). I then get the contents of that directory, but it gives me all the paths as "/private/var/.../Foo/...". This makes it hard to determine the least path that makes them unique without hard-coding knowledge about "/private" into my code. On Nov 16, 2013, at 10:52 , Charles Srstka <[email protected]> wrote: > On Nov 16, 2013, at 12:24 PM, Mike Abdullah <[email protected]> wrote: > >> How about using -fileReferenceURL on everything? That won't give you a >> normalized *path* as such, but should give you consistent URLs for >> identifying individual files >> >> Mike. > > You could also use getResourceValue:forKey:error: on the URLs with > NSURLFileResourceIdentifierKey as the key, and compare the resulting objects. > > The one caveat of this is that the file resource identifiers will be equal if > the files have the same inode, so comparing two hard links of the same file > (for example, /bin/rm and /bin/unlink) will turn up the result that the files > are equal, despite having different paths. If that isn't an issue, though, > then this is a pretty consistent way to compare files. > > Charles > -- Rick
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Cocoa-dev mailing list ([email protected]) Please 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
