Lisp HUG Maillist Archive

How to resolve file aliases in LW Mac?

Hi, does anybody know how to get the real directory of an alias?

(directory "path/*.*") returns the alias files fine, but I did not 
find any function that would convert the alias as a physical 
directory path.

(directory <alias file>) looks like not working ... am I doing something wrong?

My alias points to a directory which resides in an external hard disk 
and I would like to get its directory listing.

Are there any examples how to use aliases in LW 5 and 6 Mac editions?

Pekka


Re: How to resolve file aliases in LW Mac?


On Aug 2, 2011, at 10:52 AM, Pekka Tolonen wrote:

> Hi, does anybody know how to get the real directory of an alias?

A little background first. Mac OS X aliases are *not* merely symbolic links. A symlink looks like an alias in the Finder, but an alias created by a user in the Finder is *not* merely a unix symlink, but a Mac OS X file system data structure.

LWM can handle symlinks:

CL-USER 56 > (load "~/lispworks/ants2symlink.lisp")
; Loading text file /Users/raffaelc/lispworks/ants2.lisp
#P"/Users/raffaelc/lispworks/ants2.lisp"

but LWM cannot handle (i.e., resolve) Finder aliases:

CL-USER 57 > (load "~/lispworks/ants2finder-alias.lisp")
; Loading text file /Users/raffaelc/lispworks/ants2finder-alias.lisp

Error: Cannot read character U+0096 as part of a token because it has constituent trait 'invalid'.
  1 (continue) Try loading ~/lispworks/ants2finder-alias.lisp again.
  2 Give up loading ~/lispworks/ants2finder-alias.lisp.
  3 Try loading another file instead of ~/lispworks/ants2finder-alias.lisp.
  4 (abort) Return to level 0.
  5 Return to top loop level 0.

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.

CL-USER 58 : 1 > 

In addition, NSFileManager cannot handle Finder aliases either. You need to use  the Alias Manager:

<http://developer.apple.com/library/mac/#documentation/Carbon/Reference/Alias_Manager/Reference/reference.html>

hth,

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro@me.com






Updated at: 2020-12-10 08:37 UTC