Re: NSRecentDocumentRecords - dynamically updating
Re: NSRecentDocumentRecords - dynamically updating
- Subject: Re: NSRecentDocumentRecords - dynamically updating
- From: "James Wettenhall" <email@hidden>
- Date: Wed, 14 Mar 2007 16:26:14 +1100 (EST)
- Importance: Normal
Hi Jerry,
Thanks very much for that! I just tried your SSPathResolveFromAliasData
function in my code and it works perfectly!
>From reading your post, I'm not sure what you want to do.
Sorry about that. When I first started writing the post, I thought I
would ask specifically how to resolve the NSData objects from the
NSRecentDocumentRecords in the PList file, which is exactly what you have
helped me with. But then I thought I would be a little bit more open to
other possibilities, in case anyone wanted to suggest a completely
different approach.
Best wishes,
James
Most of what
>> you
> said will work. For example, if you want to get a path from that
> "_NSAlias", you just get that -objectForKey, cast it as an NSData and
> resolve the alias. I've pasted in a function I use to do that; I don't
> know
> maybe this is the same as what you've already found...
>
> Jerry Krinock
>
> NSString* SSPathResolveFromAliasData(NSData* data) {
> NSString* path = nil ;
> if (data) {
> if (CFDataGetTypeID() == CFGetTypeID((CFDataRef)data)) {
> // now convert the CF data back into an alias
> CFIndex dataSize = CFDataGetLength((CFDataRef)data) ;
> AliasHandle tAliasHdl = (AliasHandle)NewHandle(dataSize) ;
> if (tAliasHdl) {
> CFDataGetBytes(
> (CFDataRef)data,
> CFRangeMake(0,dataSize),
> (UInt8*)*tAliasHdl) ;
> FSRef fsRef;
> Boolean wasChanged;
> // Try to resolve the alias ...
> // The following can delay for several minutes before
> timing
> out
> // if the alias is on a volume which is not now mounted.
> // There is a related function which aborts if user
> // interaction is needed; I haven't tried that
> OSErr err = FSResolveAlias(
> NULL, tAliasHdl, &fsRef, &wasChanged) ;
> char pathC[2048] ;
> if (err == noErr) {
> err = FSRefMakePath(&fsRef, (UInt8*)pathC,
> sizeof(pathC)) ;
> }
> if (err == noErr) {
> path = [NSString stringWithCString:pathC] ;
> }
> }
> }
> }
>
> return path ;
> }
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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