Re: [toolbox] aliases vs. paths (was: Extended Attributes)
Status: Planning
Brought to you by:
jlaurens
From: Maxwell, A. R <ada...@pn...> - 2005-07-06 18:21:41
|
On Jul 6, 2005, at 10:45, J=E9r=F4me Laurens wrote: > > Le 6 juil. 05, =E0 17:54, Maxwell, Adam R a =E9crit : > > >> >> On Jul 6, 2005, at 08:16, Jon Guyer wrote: >> >> >>> >>> On Jul 6, 2005, at 10:18 AM, J=E9r=F4me Laurens wrote: >>> >>> >>> >>>> What will happen if I duplicate a file, for example by copying =20 >>>> it on a USB memory key, then copy it on my home computer, then =20 >>>> copy it back. What is the location pointed to by the alias? It =20 >>>> might be consistent but not correct. >>>> This is an example where the path can be correct but the alias =20 >>>> can be broken. >>>> On the other hand, changing a file name will break the stored =20 >>>> path but not the alias. >>>> >>>> >>> >>> Aliases can be relative <http://developer.apple.com/samplecode/=20 >>> resolveRelativeAlias/resolveRelativeAlias.html> >>> >> >> Or if you don't grok Pascal (or whatever that sample is :)... >> >> <http://developer.apple.com/documentation/MacOSX/Conceptual/=20 >> BPFileSystem/Concepts/Aliases.html> has some info on relative =20 >> paths vs. aliases. >> >> If you're using Cocoa, BDAlias is useful for working with aliases =20 >> and paths, especially for serializing aliases: <http://=20 >> bdistributed.com/Projects/BDAlias/>. >> >> My own view is that hard-coded paths in plists and code are evil, =20 >> whether they are paths to a recent file, Application Support, =20 >> Preferences, or a temp directory. >> >> -- Adam >> >> >> > > could not get this to work: > > create a new cocoa application project, add BDAlias, and use the =20 > following main > [...] > > > In the nib, subclass the NSApplication to add a =20 > createRelativeAlias: message, and a textField outlet. > Make the owner an instance of this class. Or create a Cocoa application and add a controller object as NSApp =20 delegate, which is what I just did. > > Run the app. The alias created does not take into account the =20 > NSHomeDirectory()/Documents as absolute reference. > > Things are complicated. I think this is expected behavior. If you check the docs for =20 FSResolveAlias, the relativePath part is just a starting place for =20 finding the path to the FSRef. Did it not return the correct full path? If you want a relative path in Unix terms, things get pretty =20 complicated, although stringByAbbreviatingWithTildeInPath usually =20 (but not always) works to give you a home directory-relative path. Adam= |