• 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 do I get a file reference w/o relying on the path?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I get a file reference w/o relying on the path?


  • Subject: Re: How do I get a file reference w/o relying on the path?
  • From: Charles Srstka <email@hidden>
  • Date: Sun, 4 Apr 2010 20:15:57 -0500

On Apr 4, 2010, at 12:50 PM, Jens Alfke wrote:

> You're saying that if I have a FSRef to a file, then the file is moved, the FSRef will still reference the moved file and not the location where it used to be?
>
> That's surprising to me, because FSRefs were created as a replacement for FSSpecs, which do not have that property (they were a struct {volume ID, dir ID, filename}.)
>
> Anyway, note that a file inode ID is more fragile than an alias/bookmark, because it won't survive the common practice of replacing an old copy of a file with a new one ("safe save") unless the code doing the replace is careful to propagate metadata to the new file.
>
> --Jens {via iPad}

This is the way FSRefs work. However, AliasRecords always contained both the path *and* the file ID. I believe it used the path first, and if it didn’t find a file there, then it fell back on the file ID. There were, of course, ways to alter this default behavior, such as the kResolveAliasTryFileIDFirst flag, which reversed the default resolution behavior, and the FSNewAliasMinimal() function, which left out one of the two ways of finding the file (I think it kept the file ID and left out the path, but I could be misremembering). Anyway, I’d be pretty surprised if the new bookmark feature didn’t also include this functionality.

By the way, it’s not the file inode ID that a FSRef points to, it’s the catalog node ID. The ID is actually a property of the catalog B-tree node rather than the file itself - if you have a file that has multiple hard links, each hard link will have the same inode but a different CNID.

Charles_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >How do I get a file reference w/o relying on the path? (From: Brad Stone <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Ken Thomases <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Jens Alfke <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Ken Thomases <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: [iPhone]Is it possible for apps to use the file sharing directory?
  • Next by Date: Re: Two text fields, one outlet?
  • Previous by thread: Re: How do I get a file reference w/o relying on the path?
  • Next by thread: Re: How do I get a file reference w/o relying on the path?
  • Index(es):
    • Date
    • Thread