(delete-matching-items components string-null?)))
(define (parse-directory-component component)
- (if (string=? ".." component)
- 'UP
- component))
+ (cond ((string=? ".." component) 'UP)
+ ((string=? "." component) 'HERE)
+ (else component)))
(define (string-components string delimiter)
(substring-components string 0 (string-length string) delimiter))
(define (unparse-directory-component component)
(cond ((eq? component 'UP) "..")
+ ((eq? component 'HERE) ".")
((string? component) component)
(else
(error:illegal-pathname-component component "directory component"))))
(lambda (element)
(if (string? element)
(not (string-null? element))
- (eq? element 'UP)))))
+ (memq element '(UP HERE))))))
(simplify-directory directory))
(else
(error:illegal-pathname-component directory "directory")))
(let ((directory (pathname-directory pathname)))
(let scan ((p (list-tail directory np)) (np np))
(if (pair? p)
- (if (and (not (eq? (car p) 'UP))
- (pair? (cdr p))
- (eq? (cadr p) 'UP))
- (let ((pathname*
- (pathname-new-directory pathname
- (delete-up directory p))))
- (if (file-eq? (directory-pathname pathname)
- (directory-pathname pathname*))
- (loop pathname* np)
- (scan (cddr p) (+ np 2))))
- (scan (cdr p) (+ np 1)))
+ (cond ((and (not (eq? (car p) 'UP))
+ (pair? (cdr p))
+ (eq? (cadr p) 'UP))
+ (let ((pathname*
+ (pathname-new-directory pathname
+ (delete-up directory p))))
+ (if (file-eq? (directory-pathname pathname)
+ (directory-pathname pathname*))
+ (loop pathname* np)
+ (scan (cddr p) (+ np 2)))))
+ ((eq? (car p) 'HERE)
+ (let ((pathname*
+ (pathname-new-directory pathname
+ (delete-here directory p))))
+ (loop pathname* np)))
+ (else
+ (scan (cdr p) (+ np 1))))
pathname))))
pathname))
(cddr p*)
(cons (car p*) (loop (cdr p*))))))
+(define (delete-here directory p)
+ (let loop ((p* directory))
+ (if (eq? p* p)
+ (cdr p)
+ (cons (car p*) (loop (cdr p*))))))
+
(define (file-eq? p1 p2)
((ucode-primitive file-eq? 2) (->namestring (merge-pathnames p1))
(->namestring (merge-pathnames p2))))
\ No newline at end of file