diff --git a/libguile/filesys.c b/libguile/filesys.c
index 70dfe15..6e0edb2 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1511,6 +1511,11 @@ SCM_DEFINE (scm_lstat, "lstat", 1, 0, 0,
 #undef FUNC_NAME
 #endif /* HAVE_LSTAT */
 
+/* For Windows/mingw. */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
             (SCM oldfile, SCM newfile),
 	    "Copy the file specified by @var{path-from} to @var{path-to}.\n"
@@ -1530,7 +1535,7 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
   c_newfile = scm_to_locale_string (newfile);
   scm_dynwind_free (c_newfile);
 
-  oldfd = open_or_open64 (c_oldfile, O_RDONLY);
+  oldfd = open_or_open64 (c_oldfile, O_RDONLY | O_BINARY);
   if (oldfd == -1)
     SCM_SYSERROR;
 
@@ -1543,7 +1548,7 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
     goto err_close_oldfd;
 
   /* use POSIX flags instead of 07777?.  */
-  newfd = open_or_open64 (c_newfile, O_WRONLY | O_CREAT | O_TRUNC,
+  newfd = open_or_open64 (c_newfile, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
                           oldstat.st_mode & 07777);
   if (newfd == -1)
     {
