Alain wrote: > I'm on the way to converting my prefs to CFPreferences, but I'm > stuck at the moment with a specific problem whose solution eludes me. > > We've been used to store file information as aliases in the > resource fork of our preference files, haven't we? Now that > resources are deprecated in OS X, what is the correct way to handle > such a situation? > > In the first plist I have examined, I have seen a file path and I > thought that was the new method recommended by Apple. I modified my > program so that it could store that info in the preference file. So > far, so good. But, all my attempts to convert back the file path to > an FSSpec, via an FSRef, have failed up to now. > > Furthermore, I'm not sure this is really the way to go, because if > the end-user changes in the Finder any folder name belonging to the > path or the file name, I believe the path will be broken. > > Anybody has an answer to this question? > Alain, I added these functions to the CFPrefs library a couple days ago. Hope they help. Bernie '---------- // Aliases.h toolbox fn FSNewAlias( const FSRef * fromFile, const FSRef * target, Handle * inAlias ) = OSErr toolbox fn FSResolveAlias( const FSRef * fromFile, Handle alias, FSRef * target, Boolean * wasChanged ) = OSErr // CFPrefsGetFSRef takes no default parameter. local mode local fn CFPrefsGetFSRef( key as Str255, @fsRef as ^FSRef ) '~'1 dim as Handle @ h dim as Boolean fromPrefs, @ wasChanged h = 0 fromPrefs = fn CFPrefsGetHandle( key, @h ) long if ( fromPrefs ) if ( fn FSResolveAlias( #0, h, #fsRef, @wasChanged ) ) then fromPrefs = _false DisposeHandle( h ) end if end fn = fromPrefs local mode local fn CFPrefsSetFSRef( key as Str255, fsRef as ^FSRef ) '~'1 dim as Handle @ h h = 0 long if ( fn FSNewAlias( #0, #fsRef, @h ) == _noErr ) fn CFPrefsSetHandle( key, h ) DisposeHandle( h ) end if end fn // CFPrefsGetFSSpec takes no default parameter. local mode local fn CFPrefsGetFSSpec( key as Str255, @fs as ^FSSpec ) '~'1 dim as Handle @ h dim as Boolean fromPrefs, @ wasChanged h = 0 fromPrefs = fn CFPrefsGetHandle( key, @h ) long if ( fromPrefs ) if ( fn ResolveAlias( #0, h, #fs, @wasChanged ) ) then fromPrefs = _false DisposeHandle( h ) end if end fn = fromPrefs local mode local fn CFPrefsSetFSSpec( key as Str255, fs as ^FSSpec ) '~'1 dim as Handle @ h h = 0 long if ( fn NewAlias( #0, #fs, @h ) == _noErr ) fn CFPrefsSetHandle( key, h ) DisposeHandle( h ) end if end fn '----------