From: Chris Hanson Date: Mon, 6 Nov 1995 21:52:33 +0000 (+0000) Subject: Reconcile various versions of file-copying primitives. X-Git-Tag: 20090517-FFI~5754 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=b8b1e561d963642d4f5977819a4277cd63c4dd39;p=mit-scheme.git Reconcile various versions of file-copying primitives. --- diff --git a/v7/src/microcode/dosfs.c b/v7/src/microcode/dosfs.c index 1605ee64f..78110b0ae 100644 --- a/v7/src/microcode/dosfs.c +++ b/v7/src/microcode/dosfs.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: dosfs.c,v 1.4 1992/10/21 00:27:11 jinx Exp $ +$Id: dosfs.c,v 1.5 1995/11/06 21:51:03 cph Exp $ -Copyright (c) 1992 Massachusetts Institute of Technology +Copyright (c) 1992-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -117,6 +117,30 @@ DEFUN (OS_file_rename, (from_name, to_name), error_system_call (errno, syscall_rename); } +void +DEFUN (OS_file_copy, (from_name, to_name), + CONST char * from_name AND + CONST char * to_name) +{ + int result; + Tchannel source_channel = (OS_open_input_file (from_name)); + Tchannel destination_channel = (OS_open_output_file (to_name)); + off_t source_length = (OS_file_length (source_channel)); + + result = (OS_channel_copy (source_length, + source_channel, + destination_channel)); + + OS_channel_close (source_channel); + OS_channel_close (destination_channel); + + if (result < 0) + { + signal_error_from_primitive (ERR_IO_ERROR); + } + return; +} + void DEFUN (OS_directory_make, (name), CONST char * name) { diff --git a/v7/src/microcode/os2fs.c b/v7/src/microcode/os2fs.c index 1c333c770..f24b671e5 100644 --- a/v7/src/microcode/os2fs.c +++ b/v7/src/microcode/os2fs.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: os2fs.c,v 1.6 1995/10/23 06:16:20 cph Exp $ +$Id: os2fs.c,v 1.7 1995/11/06 21:51:37 cph Exp $ Copyright (c) 1994-95 Massachusetts Institute of Technology @@ -225,6 +225,18 @@ OS_file_link_soft (const char * from_name, const char * to_name) OS2_error_unimplemented_primitive (); } +void +OS_file_copy (const char * from, const char * to) +{ + FILESTATUS3 * info = (OS2_read_file_status (to)); + if ((info != 0) && (((info -> attrFile) & FILE_READONLY) != 0)) + { + (info -> attrFile) &=~ FILE_READONLY; + OS2_write_file_status (to, info); + } + STD_API_CALL (dos_copy, (((PSZ) from), ((PSZ) to), DCPY_EXISTING)); +} + void OS_directory_make (const char * directory_name) { diff --git a/v7/src/microcode/pros2fs.c b/v7/src/microcode/pros2fs.c index 5c5f005c1..4c7055d2d 100644 --- a/v7/src/microcode/pros2fs.c +++ b/v7/src/microcode/pros2fs.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: pros2fs.c,v 1.14 1995/11/06 21:50:55 cph Exp $ +$Id: pros2fs.c,v 1.15 1995/11/06 21:52:24 cph Exp $ Copyright (c) 1994-95 Massachusetts Institute of Technology @@ -42,6 +42,7 @@ extern void OS2_write_file_status (const char *, FILESTATUS3 *); extern char * OS2_drive_type (char); extern long OS2_timezone (void); extern long OS2_daylight_savings_p (void); +extern void EXFUN (OS_file_copy, (CONST char *, CONST char *)); #ifndef FILE_TOUCH_OPEN_TRIES #define FILE_TOUCH_OPEN_TRIES 5 diff --git a/v7/src/microcode/prosfs.c b/v7/src/microcode/prosfs.c index 8bb7b8309..6e8830759 100644 --- a/v7/src/microcode/prosfs.c +++ b/v7/src/microcode/prosfs.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: prosfs.c,v 1.11 1992/10/21 00:27:22 jinx Exp $ +$Id: prosfs.c,v 1.12 1995/11/06 21:52:33 cph Exp $ Copyright (c) 1987-1992 Massachusetts Institute of Technology @@ -47,6 +47,7 @@ extern int EXFUN (OS_channel_copy, (off_t source_length, Tchannel source_channel, Tchannel destination_channel)); +extern void EXFUN (OS_file_copy, (CONST char *, CONST char *)); #define STRING_RESULT(expression) \ { \ @@ -201,30 +202,6 @@ DEFUN (OS_channel_copy, (source_length, source_channel, destination_channel), return (0); } -void -DEFUN (OS_file_copy, (from_name, to_name), - CONST char * from_name AND - CONST char * to_name) -{ - int result; - Tchannel source_channel = (OS_open_input_file (from_name)); - Tchannel destination_channel = (OS_open_output_file (to_name)); - off_t source_length = (OS_file_length (source_channel)); - - result = (OS_channel_copy (source_length, - source_channel, - destination_channel)); - - OS_channel_close (source_channel); - OS_channel_close (destination_channel); - - if (result < 0) - { - signal_error_from_primitive (ERR_IO_ERROR); - } - return; -} - DEFINE_PRIMITIVE ("FILE-COPY", Prim_file_copy, 2, 2, "Make a new copy of the file FROM-NAME, called TO-NAME.") { diff --git a/v7/src/microcode/uxfs.c b/v7/src/microcode/uxfs.c index 160e28140..002481d0e 100644 --- a/v7/src/microcode/uxfs.c +++ b/v7/src/microcode/uxfs.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: uxfs.c,v 1.9 1992/10/21 00:26:46 jinx Exp $ +$Id: uxfs.c,v 1.10 1995/11/06 21:51:12 cph Exp $ -Copyright (c) 1990-1992 Massachusetts Institute of Technology +Copyright (c) 1990-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -120,7 +120,7 @@ DEFUN (OS_file_soft_link_p, (name), CONST char * name) return (0); #endif } - + int DEFUN (OS_file_access, (name, mode), CONST char * name AND unsigned int mode) { @@ -145,7 +145,7 @@ DEFUN (OS_file_remove_link, (name), CONST char * name) )) UX_unlink (name); } - + void DEFUN (OS_file_link_hard, (from_name, to_name), CONST char * from_name AND @@ -174,6 +174,30 @@ DEFUN (OS_file_rename, (from_name, to_name), STD_VOID_SYSTEM_CALL (syscall_rename, (UX_rename (from_name, to_name))); } +void +DEFUN (OS_file_copy, (from_name, to_name), + CONST char * from_name AND + CONST char * to_name) +{ + int result; + Tchannel source_channel = (OS_open_input_file (from_name)); + Tchannel destination_channel = (OS_open_output_file (to_name)); + off_t source_length = (OS_file_length (source_channel)); + + result = (OS_channel_copy (source_length, + source_channel, + destination_channel)); + + OS_channel_close (source_channel); + OS_channel_close (destination_channel); + + if (result < 0) + { + signal_error_from_primitive (ERR_IO_ERROR); + } + return; +} + void DEFUN (OS_directory_make, (name), CONST char * name) {