cs: avoid crash on startup if the working directory does not exist

Closes #3793
This commit is contained in:
Matthew Flatt 2021-04-21 11:07:59 -06:00
parent 9753eb6fb0
commit 725a7e353c
3 changed files with 19 additions and 7 deletions

View File

@ -532,7 +532,7 @@
(include "include.ss")
(include-generated "io.scm")
;; Initialize:
;; Initialize:
(set-log-system-message! (lambda (level str)
(1/log-message (|#%app| 1/current-logger) level str #f)))
(set-error-display-eprintf! (lambda (fmt . args)

View File

@ -30352,11 +30352,16 @@
(define set-run-file! (lambda (p_0) (set! run-file p_0)))
(define orig-dir
(let ((os-host-dir_0
(|#%app|
rktio_to_bytes
(|#%app|
rktio_get_current_directory
(unsafe-place-local-ref cell.1)))))
(let ((dir_0
(|#%app|
rktio_get_current_directory
(unsafe-place-local-ref cell.1))))
(if (vector? dir_0)
(let ((tmp_0 (system-path-convention-type)))
(if (eq? tmp_0 'unix)
#vu8(47)
(if (eq? tmp_0 'windows) #vu8(67 58 92) (void))))
(|#%app| rktio_to_bytes dir_0)))))
(let ((os-dir_0 (1/path->directory-path (host-> os-host-dir_0))))
(let ((tmp_0 (system-type 'os)))
(if (eq? tmp_0 'windows)

View File

@ -71,7 +71,14 @@
(define orig-dir
(let ()
(define os-host-dir (rktio_to_bytes (rktio_get_current_directory rktio)))
(define os-host-dir (let ([dir (rktio_get_current_directory rktio)])
(if (rktio-error? dir)
;; If there's an error getting the current directory,
;; just use a root directory
(case (system-path-convention-type)
[(unix) #"/"]
[(windows) #"C:\\"])
(rktio_to_bytes dir))))
(define os-dir (path->directory-path (host-> os-host-dir)))
(case (system-type 'os)
[(windows) os-dir]