File: hln.lisp

package info (click to toggle)
clisp 1%3A2.44.1-4.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 40,080 kB
  • ctags: 12,945
  • sloc: lisp: 77,546; ansic: 32,166; xml: 25,161; sh: 11,568; fortran: 7,094; cpp: 2,636; makefile: 1,234; perl: 164
file content (24 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!@CLISP@ -C
;; work around a possible bug in ln(1) on symbolic links:
;; according to the Linux ln(1):
;;    "making a hard link to a symbolic link is not portable":
;; SVR4 (Solaris, Linux) create symbolic links
;;    (breaks when the target is relative)
;; Cygwin (1.3.12) is even worse: it makes hard links to the symbolic link,
;;    instead of resolving the symbolic link.
;; Good behavior means creating a hard link to the symbolic link's target.
;; this bug is detected by CL_PROG_HLN in src/m4/ln.m4
;; cf gl_AC_FUNC_LINK_FOLLOWS_SYMLINK in gnulib/m4/link-follow.m4
;;
;; To avoid this, use this lisp program: the syscalls module works
;; around the above difficulty

(unless (cdr *args*)
  (error "~A(~S): too few arguments" *load-truename* *args*))
(setq *args* (nreverse *args*))
(defparameter *dest* (pop *args*))
(when (cdr *args*) ; more than 2 arguments ==> destination must be a directory
  (unless (char= #\/ (char *dest* (1- (length *dest*))))
    (setq *dest* (string-concat *dest* "/"))))
(dolist (f *args*)
  (posix:copy-file f *dest* :method :hardlink))