From: Taylor R Campbell Date: Wed, 23 Mar 2011 04:34:00 +0000 (+0000) Subject: When signalling a file open error, read channel type before closing. X-Git-Tag: 20110426-Gtk~2^2~27 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=2e5ec74875f87204e1060a4d696dfa687d779d72;p=mit-scheme.git When signalling a file open error, read channel type before closing. --- diff --git a/src/runtime/io.scm b/src/runtime/io.scm index 1bca8e7ad..f92299034 100644 --- a/src/runtime/io.scm +++ b/src/runtime/io.scm @@ -288,18 +288,15 @@ USA. (let ((channel (open-channel (lambda (p) (primitive filename p))))) (if (or (channel-type=directory? channel) (channel-type=unknown? channel)) - (begin + (let ((reason + (if (channel-type=directory? channel) + "Is a directory" + "Unknown file type"))) (channel-close channel) (file-open primitive operator - (error:file-operation filename - "open" - "file" - (if (channel-type=directory? channel) - "Is a directory" - "Unknown file type") - operator - (list filename)))) + (error:file-operation filename "open" "file" reason + operator (list filename)))) channel))) (define (file-open-input-channel filename)