{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,22 +15,32 @@
|
|||
utilities for working with package paths and installed-package
|
||||
databases.}
|
||||
|
||||
@defstruct[pkg-info ([orig-pkg (or/c (list/c 'catalog string?)
|
||||
(list/c 'url string?)
|
||||
(list/c 'link string?)
|
||||
(list/c 'static-link string?))]
|
||||
[checksum (or/c #f string?)]
|
||||
[auto? boolean?])
|
||||
#:prefab]{
|
||||
@defstruct*[pkg-info ([orig-pkg (or/c (list/c 'catalog string?)
|
||||
(list/c 'url string?)
|
||||
(list/c 'link string?)
|
||||
(list/c 'static-link string?))]
|
||||
[checksum (or/c #f string?)]
|
||||
[auto? boolean?])
|
||||
#:prefab]{
|
||||
|
||||
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
|
||||
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?]
|
||||
[#:cache cache (or/c #f (and/c hash? (not/c immutable?)))])
|
||||
|
|
|
@ -66,9 +66,15 @@
|
|||
(delete-directory path)]
|
||||
[else
|
||||
(when must-exist?
|
||||
(error 'delete-directory/files
|
||||
"encountered ~a, neither a file nor a directory"
|
||||
path))])))
|
||||
(raise-not-a-file-or-directory 'delete-directory/files 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
|
||||
#:keep-modify-seconds? [keep-modify-seconds? #f])
|
||||
|
@ -85,9 +91,7 @@
|
|||
(loop (build-path src e)
|
||||
(build-path dest e)))
|
||||
(sorted-dirlist src))]
|
||||
[else (error 'copy-directory/files
|
||||
"encountered ~a, neither a file nor a directory"
|
||||
src)])))
|
||||
[else (raise-not-a-file-or-directory 'copy-directory/files src)])))
|
||||
|
||||
(define (make-directory* dir)
|
||||
(let-values ([(base name dir?) (split-path dir)])
|
||||
|
|
Loading…
Reference in New Issue
Block a user