fix rename-file-or-directory for raising exn:failsystem:fail:exists

Broken by 0133954c84, which avoided a made-up `EEXIST` but left in
place a no-loner-appropriate test for raising `exn:failsystem:fail:exists`.
This commit is contained in:
Matthew Flatt 2016-11-29 07:20:12 -07:00
parent af555731a6
commit 200fbe9b95
2 changed files with 5 additions and 4 deletions

View File

@ -64,6 +64,7 @@
(define delete-file/tf (lambda (x) ((make-/tf delete-file exn:fail:filesystem?) x)))
(define delete-directory/tf (lambda (x) ((make-/tf delete-directory exn:fail:filesystem?) x)))
(define rename-file-or-directory/tf (lambda (x y) ((make-/tf rename-file-or-directory exn:fail:filesystem?) x y)))
(define rename-file-or-directory/exists/tf (lambda (x y) ((make-/tf rename-file-or-directory exn:fail:filesystem:exists?) x y)))
(define make-directory/tf (lambda (x) ((make-/tf make-directory exn:fail:filesystem?) x)))
(define copy-file/tf (lambda (x y) ((make-/tf copy-file exn:fail:filesystem?) x y)))
@ -191,8 +192,8 @@
(close-output-port (open-output-file "tmp5"))
(test #t file-exists? "tmp5")
(test #t file-exists? "tmp5x")
(test #f rename-file-or-directory/tf "tmp5" "tmp5x")
(test #f rename-file-or-directory/tf "tmp5" "down")
(test #f rename-file-or-directory/exists/tf "tmp5" "tmp5x")
(test #f rename-file-or-directory/exists/tf "tmp5" "down")
(delete-file "tmp5")
(test #f file-exists? "tmp5")
(test #t rename-file-or-directory/tf (build-path "down" "tmp8") (build-path "down" "tmp8x"))
@ -201,7 +202,7 @@
(test #f rename-file-or-directory/tf (build-path deepdir "tmp7") (build-path deepdir "tmp7x"))
(test #t make-directory/tf "downx")
(test #f rename-file-or-directory/tf "down" "downx")
(test #f rename-file-or-directory/exists/tf "down" "downx")
(test #t delete-directory/tf "downx")
(test #t rename-file-or-directory/tf "down" "downx")

View File

@ -4300,7 +4300,7 @@ static Scheme_Object *rename_file(int argc, Scheme_Object **argv)
/* We use a specialized error message here, because it's not
a system error (e.g., setting `errno` to `EEXIST` would
be a lie). */
scheme_raise_exn((exists_ok < 0) ? MZEXN_FAIL_FILESYSTEM_EXISTS : MZEXN_FAIL_FILESYSTEM,
scheme_raise_exn(MZEXN_FAIL_FILESYSTEM_EXISTS,
"rename-file-or-directory: cannot rename file or directory;\n"
" the destination path already exists\n"
" source path: %q\n"