2005-05-22 11:05:25 -04:00
|
|
|
(define-record-type fs-object :fs-object
|
2005-05-26 07:35:17 -04:00
|
|
|
(really-make-fs-object name path info)
|
2005-05-22 11:05:25 -04:00
|
|
|
fs-object?
|
|
|
|
(name fs-object-name)
|
2005-05-26 07:35:17 -04:00
|
|
|
(path fs-object-path)
|
2005-05-27 05:53:06 -04:00
|
|
|
(info really-fs-object-info))
|
|
|
|
|
|
|
|
(define (fs-object-info fso)
|
|
|
|
(force (really-fs-object-info fso)))
|
2005-05-26 07:35:17 -04:00
|
|
|
|
|
|
|
(define (make-fs-object name path)
|
2005-05-27 17:32:21 -04:00
|
|
|
;; TODO check path for being absolute, name for being relative
|
|
|
|
;; and slashless
|
|
|
|
(if (not (file-name-absolute? path))
|
|
|
|
(error "path argument of make-fs-object not absolute" path))
|
2005-05-26 07:35:17 -04:00
|
|
|
(really-make-fs-object
|
|
|
|
name path
|
2005-05-27 17:32:21 -04:00
|
|
|
;; TODO: this delay is rather useless, we need the info anyway
|
2005-05-27 05:53:06 -04:00
|
|
|
(delay
|
|
|
|
(with-fatal-error-handler
|
|
|
|
(lambda (condition more)
|
|
|
|
(format #t "condition while fs-object-info: ~a" condition)
|
|
|
|
#f)
|
|
|
|
(file-info (combine-path path name))))))
|
2005-05-22 11:05:25 -04:00
|
|
|
|
|
|
|
(define-record-discloser :fs-object
|
|
|
|
(lambda (r)
|
2005-05-27 17:32:21 -04:00
|
|
|
`(fs-object ,(fs-object-path r) ,(fs-object-name r))))
|
2005-05-26 07:35:17 -04:00
|
|
|
|
|
|
|
(define (combine-path parent name)
|
|
|
|
(if (string=? parent "")
|
|
|
|
name
|
|
|
|
(string-append parent
|
|
|
|
"/"
|
|
|
|
name)))
|
|
|
|
|
|
|
|
(define (fs-object-complete-path fs-object)
|
2005-05-27 17:32:21 -04:00
|
|
|
(absolute-file-name
|
|
|
|
(fs-object-name fs-object)
|
|
|
|
(fs-object-path fs-object)))
|
|
|
|
|
|
|
|
(define (file-name->fs-object file-name)
|
|
|
|
(if (file-name-absolute? file-name)
|
|
|
|
(make-fs-object (file-name-nondirectory file-name)
|
|
|
|
(file-name-directory file-name))
|
|
|
|
(error "WRITE-ME file-name->fs-object")))
|