Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFURLGetFSRef resolving symlinks (Re: FSGet/SetCatalogInfo following symlinks)



On Mon, 12 Sep 2005 22:04:25, Rainer Brockerhoff <email@hidden>
wrote:

> At 16:01 -0400 9/12/05, Laurence Harris wrote:
>> On 9/12/05 11:57 AM, Rainer Brockerhoff didst favor us with:
>>> As I have similar motives for examining symlinks before resolving them (if
>>> at
>>> all), I'm playing it safe by always descending through the path components
>>> with FSMakeFSRefUnicode. I avoid using CFURL entirely. This also works
>>> around
>>> the 1024-character path size limit, of course.
>> 
>> I avoid CFURLs as much as possible myself. I was using them here to create a
>> path for use with symlink(). But as long as we're at it, is there another
>> way to create symlinks that uses the File Manager and hence doesn't suffer
>> from the path length limitation?
> 
> Well, in general I found that if you need to use a BSD call (like, say
> lstat()) it pays to walk down the path components by calling chdir(). If you
> need File Manager calls, walk down calling FSMakeFSRefUnicode. This is the
> only way to get around the limit.
> 
> However, symlink() takes two different paths, so some magic would be necessary
> here; something like creating the symlink in a known "short path" location
> like /tmp, getting a FSRef for it, and then moving it to the destination, or
> swapping it with FSExchangeObjects().

What a hack :)

> Another idea would be to create the link yourself as a file of type/creator
> 'slnk'/'rhap' (kSymLinkFileType/ kSymLinkFileCreator), containing the target
> path. You must also set the file type in the fileMode field of the permissions
> to S_IFLNK. This should work, although I haven't tried it myself. These
> details are in TN1150.

That would be dependence on HFS+.

BTW, "For maximum compatibility, the length of the path should be 1024 bytes
or less." Paths limitations strike again.

Mike

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.