Symbolic Links

Q&A's, tips, howto's
Locked
johnd
Posts: 18
Joined: Mon May 09, 2005 7:54 pm
Location: San Francisco, CA

Symbolic Links

Post by johnd »

Does anyone know of a way to detect a symbolic link using newlisp functions? I suspect there is a straightforward way.

Consider the following:

> !ls -l
total 6432
lrwxr-xr-x 1 11 Dec 4 16:36 testpic -> testpic.eps
-rw-r--r-- 1 2602422 Dec 4 16:32 testpic.eps
> (file-info "testpic.eps")
(2602422 33188 0 501 0 1165271560 1165271558 1165271559)
> (file-info "testpic")
(2602422 33188 0 501 0 1165271560 1165271558 1165271559)
>

These look exactly the same to file-info.

One solution is use newlisp's exec command and parse out the "l" indicating a symbolic link. I'd prefer something faster and not dependent on "ls".

Thanks.

John

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

The next development version 9.0.6 (due 12/5 or 12/6) will distinguish in the mode field (2nd field) between links and original files.

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Aaa nice, then recurcive directory walks will finaly work under linux ;-)
-- (define? (Cornflakes))

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

newdep wrote:Aaa nice, then recurcive directory walks will finaly work under linux ;-)
yes - I had a problem in this respect when trying to write a find-duplicates script http://newlisper.blogspot.com/2005/12/f ... cos-x.html (one of my first newLISP scripts). I discovered that one of the Python guys had put a link to a file further up the directory tree in one of his applications:

Code: Select all

/Users/me/Library/ScriptingAdditions/TextCommands.app/
Contents/Frameworks/Python.framework/Versions/2.3/Frameworks
/Python.framework/Versions/2.3/Frameworks/Python.framework/
Versions/2.3/Frameworks/Python.framework/Versions/2.3/
Frameworks/Python.framework/Versions/2.3/Frameworks/Python.
framework/Versions/2.3/Frameworks/Python.framework/Versions/
2.3/Frameworks/Python.framework/Versions/2.3/Frameworks/
Python.framework/Versions/2.3/Frameworks/Python.framework/
Versions/2.3/Frameworks/Python.framework/Versions/2.3/
Frameworks/Python.framework/Versions/2.3/Frameworks/Python.
framework/Versions/2.3/Frameworks/Python.framework/Versions/
2.3/Frameworks/Python.framework/Versions/2.3/Frameworks/
Python.framework/Versions/2.3/Frameworks/Python.framework/
Versions/2.3/Frameworks/Python.framework/Versions/2.3/
Frameworks/Python.framework/Versions/2.3/Frameworks/Python.
framework/Versions/2.3/Frameworks/Python.framework/Versions/
2.3/Frameworks/Python.framework/Versions/2.3/Frameworks/
Python.framework/Versions/2.3/Python
newLISP used to not like this (v8), but strangely it doesn't complain any more - just goes for about 40 circuits then appears to realise what's happening and moves on.... Lutz must've added some AI or something! ;-)

Locked