{copy/delete}-directory/files: raise "not dir or file" as exn:fail:filesystem
When a bad path is encountered, the problem should count as a filesystem exception so that it can be caught with other filesystem exceptions.
This commit is contained in:
parent
b83373d6a4
commit
a2e75d1ff2
|
@ -15,7 +15,7 @@
|
||||||
utilities for working with package paths and installed-package
|
utilities for working with package paths and installed-package
|
||||||
databases.}
|
databases.}
|
||||||
|
|
||||||
@defstruct[pkg-info ([orig-pkg (or/c (list/c 'catalog string?)
|
@defstruct*[pkg-info ([orig-pkg (or/c (list/c 'catalog string?)
|
||||||
(list/c 'url string?)
|
(list/c 'url string?)
|
||||||
(list/c 'link string?)
|
(list/c 'link string?)
|
||||||
(list/c 'static-link string?))]
|
(list/c 'static-link string?))]
|
||||||
|
@ -26,11 +26,21 @@ databases.}
|
||||||
A structure type that is used to report installed-package information.}
|
A structure type that is used to report installed-package information.}
|
||||||
|
|
||||||
|
|
||||||
@defstruct[(sc-pkg-info pkg-info) ()]{
|
@defstruct*[(sc-pkg-info pkg-info) ()]{
|
||||||
|
|
||||||
A structure subtype that represents a package that is installed as
|
A structure subtype that represents a package that is installed as
|
||||||
single-collection.}
|
single-collection.}
|
||||||
|
|
||||||
|
@deftogether[(
|
||||||
|
@defstruct*[(pkg-info/alt pkg-info) ([dir-name string?])]
|
||||||
|
@defstruct*[(sc-pkg-info/alt sc-pkg-info) ([dir-name string?])]
|
||||||
|
)]{
|
||||||
|
|
||||||
|
Structure subtypes that are used when the installation directory for a
|
||||||
|
package does not match the package name, but is instead
|
||||||
|
@racket[dir-name]. The directory name always includes a @litchar{+}
|
||||||
|
(which is disallowed in a package name).}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(path->pkg [path path-string?]
|
@defproc[(path->pkg [path path-string?]
|
||||||
[#:cache cache (or/c #f (and/c hash? (not/c immutable?)))])
|
[#:cache cache (or/c #f (and/c hash? (not/c immutable?)))])
|
||||||
|
|
|
@ -66,9 +66,15 @@
|
||||||
(delete-directory path)]
|
(delete-directory path)]
|
||||||
[else
|
[else
|
||||||
(when must-exist?
|
(when must-exist?
|
||||||
(error 'delete-directory/files
|
(raise-not-a-file-or-directory 'delete-directory/files path))])))
|
||||||
"encountered ~a, neither a file nor a directory"
|
|
||||||
path))])))
|
(define (raise-not-a-file-or-directory who path)
|
||||||
|
(raise
|
||||||
|
(make-exn:fail:filesystem
|
||||||
|
(format "~a: encountered ~a, neither a file nor a directory"
|
||||||
|
who
|
||||||
|
path)
|
||||||
|
(current-continuation-marks))))
|
||||||
|
|
||||||
(define (copy-directory/files src dest
|
(define (copy-directory/files src dest
|
||||||
#:keep-modify-seconds? [keep-modify-seconds? #f])
|
#:keep-modify-seconds? [keep-modify-seconds? #f])
|
||||||
|
@ -85,9 +91,7 @@
|
||||||
(loop (build-path src e)
|
(loop (build-path src e)
|
||||||
(build-path dest e)))
|
(build-path dest e)))
|
||||||
(sorted-dirlist src))]
|
(sorted-dirlist src))]
|
||||||
[else (error 'copy-directory/files
|
[else (raise-not-a-file-or-directory 'copy-directory/files src)])))
|
||||||
"encountered ~a, neither a file nor a directory"
|
|
||||||
src)])))
|
|
||||||
|
|
||||||
(define (make-directory* dir)
|
(define (make-directory* dir)
|
||||||
(let-values ([(base name dir?) (split-path dir)])
|
(let-values ([(base name dir?) (split-path dir)])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user