;; -*-Lisp-*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Description: Platform-independent replacement for ls -l ;; Author: Claus Brod ;; Language: Lisp ;; ;; (C) Copyright 2005 Claus Brod, all rights reserved ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ;; see http://www.clausbrod.de/cgi-bin/view.pl/CoCreateModeling/MacroListDirectory ;(in-package :clausbrod.de) ;(export 'ls-l) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Author: der_Wolfgang@forum@cad.de ;; ;; the code below is pure common LISP ; removing 2 Modeling specific calls in Claus' code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; i ;; . . . . I . . . i ooooo o ooooooo ooooo ooooo ;; I I I I I I I I I 8 8 8 8 8 o 8 8 ;; I I \ `+' / I I 8 8 8 8 8 8 ;; I \ `-+-' / I 8 8 8 ooooo 8oooo ;; \ `-__|__-' / 8 8 8 8 8 ;; `--___|___--' 8 o 8 8 o 8 8 ;; | ooooo 8oooooo ooo8ooo ooooo 8 ;; --------+-------- ;; ;; Welcome to GNU CLISP 2.49+ (2010-07-17) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun file-mod-time(f) (multiple-value-bind (sec minutes hour date month year) (decode-universal-time (file-write-date f)) (format nil "~D/~2,'0D/~2,'0D ~2,'0D:~2,'0D:~2,'0D" year month date hour minutes sec))) (defun inq-file-size (f) (with-open-file (stream f :direction :input :if-does-not-exist nil) (if stream (file-length stream) 0))) (defun print-file-info(s f) (format s "~A ~12D ~S~%" (file-mod-time f) (inq-file-size (namestring f)) (namestring f) )) (defun ls-l(dir pattern logfile) (with-open-file (s logfile :direction :output :if-exists :supersede) (dolist (f (directory (format nil "~A/~A" dir pattern))) (print-file-info s f)))) ;; Attention! including the logfile in the filepattern to list files does NOT work! ;; example calls: ;(ls-l "c:/temp" "*.exe" "c:/temp/ls01.txt") ;(ls-l "c:/temp" "*.pdf" "c:/temp/ls02.txt") ;(ls-l "c:/temp" "*.PDF" "c:/temp/ls03.txt")