set base-dir more sensitively

main
Matthew Butterick 4 years ago
parent c9b8c4d8bf
commit 199869b604

@ -335,13 +335,16 @@
;; and looking for fonts and other assets.
(match-define-values (base-dir _ _) (split-path
(match base-dir-arg
[#false (current-directory)]
(cond
;; for reasons unclear, DrRacket sometimes sneaks
;; an "unsaved editor" into this arg, despite efforts to prevent
;; probably my fault
["unsaved editor" pdf-path-arg]
[path path])))
[(equal? base-dir-arg "unsaved editor") pdf-path-arg]
[base-dir-arg]
[pdf-path-arg]
;; pdf-path-arg is #false when we're returning bytes,
;; but we still need some directory, so current-directory is last resort.
[else (current-directory)])))
(unless (directory-exists? base-dir)
(raise-argument-error 'render-pdf "existing directory" base-dir))

Loading…
Cancel
Save