diff --git a/collects/tests/racket/path.rktl b/collects/tests/racket/path.rktl index a6a3618953..17b7c662be 100644 --- a/collects/tests/racket/path.rktl +++ b/collects/tests/racket/path.rktl @@ -129,6 +129,8 @@ (test #f copy-file/tf "tmp5" "down") (test #f copy-file/tf "tmp5" (build-path deepdir "moredeep" "tmp5y")) (test (file-size "tmp5") file-size "tmp5y") +(err/rt-test (copy-file "tmp5" "tmp5y") exn:fail:filesystem:exists?) +(err/rt-test (copy-file "no-such-tmp5" "tmp5y") (lambda (x) (not (exn:fail:filesystem:exists? x)))) (delete-file "tmp5y") (test #t rename-file-or-directory/tf "tmp5" "tmp5x") diff --git a/src/racket/src/file.c b/src/racket/src/file.c index 225fae5a0e..c86ecf6075 100644 --- a/src/racket/src/file.c +++ b/src/racket/src/file.c @@ -3908,6 +3908,7 @@ static Scheme_Object *copy_file(int argc, Scheme_Object **argv) if (!out) { scheme_close_input_port(in); has_err_val = !!err_val; + pre_exists = (err_val == EEXIST); goto failed; }