I recently asked for code to determine whether a file is a symbolic
link or not, and thanks to help from John Williams and John Gibson
at Sussex, I now have the following, which can be installed in:
$poplocal/local/auto/issymlink.p
I believe it works on all Unix platforms. I've tried it on Suns
(Solaris and SunOS), Linux on PC and DEC Alpha.
Aaron
=======================================================================
/*
> File: $poplocal/local/auto/issymlink.p
> Purpose: Detect symbolic links
> Author: John Williams and John Gibson, Sep 8 1997
> Documentation: HELP * SYS_FILE_STAT, MAN * STAT
*/
section;
compile_mode :pop11 +strict;
lconstant
STM_IFMT = 8:170000, ;;; (mask for file type)
STM_IFLNK = 8:120000; ;;; (value for symbolic link).
define issymlink(f);
lconstant v = writeable {0 0 0 0 0};
sys_file_stat(f, v, false) and v(5) && STM_IFMT == STM_IFLNK
enddefine;
endsection;
=======================================================================
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman at cs.bham.ac.uk(||| MAKE BULK EMAIL ADVERTS ILLEGAL |||)
Phone: +44-121-414-4775 (Sec 3711) Fax: +44-121-414-4281
|