Changeset 10077


Ignore:
Timestamp:
10/04/05 16:17:06 (16 years ago)
Author:
piso
Message:

Work in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/directory.lisp

    r9975 r10077  
    22;;;
    33;;; Copyright (C) 2004-2005 Peter Graves
    4 ;;; $Id: directory.lisp,v 1.4 2005-09-14 19:59:19 piso Exp $
     4;;; $Id: directory.lisp,v 1.5 2005-10-04 16:17:06 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    2020(in-package #:system)
    2121
    22 (defun directory (pathname &key)
    23   (let ((merged-pathname (merge-pathnames pathname)))
    24     (when (typep merged-pathname 'logical-pathname)
    25       (setf merged-pathname (translate-logical-pathname merged-pathname)))
    26     (if (wild-pathname-p merged-pathname)
    27         (let ((namestring (directory-namestring merged-pathname)))
     22(defun pathname-as-file (pathname)
     23  (let ((directory (pathname-directory pathname)))
     24    (make-pathname :host nil
     25                   :device (pathname-device pathname)
     26                   :directory (butlast directory)
     27                   :name (car (last directory))
     28                   :type nil
     29                   :version nil)))
     30
     31(defun directory (pathspec &key)
     32  (let ((pathname (merge-pathnames pathspec)))
     33    (when (logical-pathname-p pathname)
     34      (setf pathname (translate-logical-pathname pathname)))
     35    (if (wild-pathname-p pathname)
     36        (let ((namestring (directory-namestring pathname)))
    2837          (when (and namestring (length namestring))
    29             (let ((all-files (list-directory namestring))
    30                   (matching-files ()))
    31               (dolist (file all-files)
    32                 (when (pathname-match-p file merged-pathname)
    33                   (push file matching-files)))
    34               matching-files)))
     38            (let ((entries (list-directory namestring))
     39                  (matching-entries ()))
     40              (dolist (entry entries)
     41                (cond ((file-directory-p entry)
     42                       (when (pathname-match-p (pathname-as-file entry) pathname)
     43                         (push entry matching-entries)))
     44                      ((pathname-match-p entry pathname)
     45                       (push entry matching-entries))))
     46              matching-entries)))
    3547        ;; Not wild.
    36         (let ((truename (probe-file merged-pathname)))
     48        (let ((truename (probe-file pathname)))
    3749          (if truename
    3850              (list (pathname truename))
Note: See TracChangeset for help on using the changeset viewer.