windows: fix `copy-file' changes
This commit is contained in:
parent
76e55071b0
commit
df43d90513
|
@ -215,7 +215,7 @@ Scheme_Config *scheme_init_error_escape_proc(Scheme_Config *config)
|
|||
%- = skip int
|
||||
|
||||
%L = line number as intptr_t, -1 means no line
|
||||
%e = error number for strerror()/FormatMessage()
|
||||
%e = error number for strerror()
|
||||
%E = error number for platform-specific error string
|
||||
%Z = potential platform-specific error number; additional char*
|
||||
is either NULL or a specific error message
|
||||
|
@ -223,6 +223,8 @@ Scheme_Config *scheme_init_error_escape_proc(Scheme_Config *config)
|
|||
or error number for scheme_hostname_error()
|
||||
%m = boolean then error number like %e, which
|
||||
is used only if the boolean is 1
|
||||
%M = boolean then error number like %E, which
|
||||
is used only if the boolean is 1
|
||||
*/
|
||||
|
||||
static intptr_t sch_vsprintf(char *s, intptr_t maxlen, const char *msg, va_list args, char **_s)
|
||||
|
@ -275,6 +277,7 @@ static intptr_t sch_vsprintf(char *s, intptr_t maxlen, const char *msg, va_list
|
|||
break;
|
||||
case 'N':
|
||||
case 'm':
|
||||
case 'M':
|
||||
ints[ip++] = mzVA_ARG(args, int);
|
||||
ints[ip++] = mzVA_ARG(args, int);
|
||||
break;
|
||||
|
@ -407,6 +410,7 @@ static intptr_t sch_vsprintf(char *s, intptr_t maxlen, const char *msg, va_list
|
|||
case 'e':
|
||||
case 'm':
|
||||
case 'E':
|
||||
case 'M':
|
||||
case 'Z':
|
||||
case 'N':
|
||||
{
|
||||
|
@ -417,6 +421,10 @@ static intptr_t sch_vsprintf(char *s, intptr_t maxlen, const char *msg, va_list
|
|||
none = !ints[ip++];
|
||||
type = 'e';
|
||||
he = 0;
|
||||
} else if (type == 'M') {
|
||||
none = !ints[ip++];
|
||||
type = 'E';
|
||||
he = 0;
|
||||
} else if (type == 'N') {
|
||||
he = ints[ip++];
|
||||
type = 'E';
|
||||
|
|
|
@ -3967,7 +3967,7 @@ static Scheme_Object *copy_file(int argc, Scheme_Object **argv)
|
|||
#endif
|
||||
|
||||
scheme_raise_exn(pre_exists ? MZEXN_FAIL_FILESYSTEM_EXISTS : MZEXN_FAIL_FILESYSTEM,
|
||||
"copy-file: %s; cannot copy: %q to: %q%s%m%s",
|
||||
"copy-file: %s; cannot copy: %q to: %q%s%M%s",
|
||||
reason,
|
||||
filename_for_error(argv[0]),
|
||||
filename_for_error(argv[1]),
|
||||
|
|
|
@ -4125,8 +4125,10 @@ scheme_do_open_input_file(char *name, int offset, int argc, Scheme_Object *argv[
|
|||
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
if (err) {
|
||||
int errv;
|
||||
errv = GetLastError();
|
||||
*err = "cannot open source file";
|
||||
*eerrno = GetLastError();
|
||||
*eerrno = errv;
|
||||
} else
|
||||
filename_exn(name, "cannot open input file", filename, GetLastError());
|
||||
return NULL;
|
||||
|
@ -4397,9 +4399,9 @@ scheme_do_open_output_file(char *name, int offset, int argc, Scheme_Object *argv
|
|||
NULL);
|
||||
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
int err;
|
||||
err = GetLastError();
|
||||
if ((err == ERROR_ACCESS_DENIED) && (existsok < -1)) {
|
||||
int errv;
|
||||
errv = GetLastError();
|
||||
if ((errv == ERROR_ACCESS_DENIED) && (existsok < -1)) {
|
||||
/* Delete and try again... */
|
||||
if (DeleteFileW(WIDE_PATH(filename))) {
|
||||
fd = CreateFileW(WIDE_PATH(filename),
|
||||
|
@ -4410,17 +4412,17 @@ scheme_do_open_output_file(char *name, int offset, int argc, Scheme_Object *argv
|
|||
0,
|
||||
NULL);
|
||||
if (fd == INVALID_HANDLE_VALUE)
|
||||
err = GetLastError();
|
||||
errv = GetLastError();
|
||||
} else {
|
||||
scheme_raise_exn(MZEXN_FAIL_FILESYSTEM,
|
||||
"%s: error deleting \"%q\" (%E)",
|
||||
name, filename, GetLastError());
|
||||
return NULL;
|
||||
}
|
||||
} else if (err == ERROR_FILE_EXISTS) {
|
||||
} else if (errv == ERROR_FILE_EXISTS) {
|
||||
if (err) {
|
||||
*err = "destination already exists";
|
||||
*eerrno = err;
|
||||
*eerrno = errv;
|
||||
} else
|
||||
scheme_raise_exn(MZEXN_FAIL_FILESYSTEM_EXISTS,
|
||||
"%s: file \"%q\" exists", name, filename);
|
||||
|
@ -4430,9 +4432,9 @@ scheme_do_open_output_file(char *name, int offset, int argc, Scheme_Object *argv
|
|||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
if (err) {
|
||||
*err = "cannot open destination";
|
||||
*eerrno = err;
|
||||
*eerrno = errv;
|
||||
} else
|
||||
filename_exn(name, "cannot open output file", filename, err);
|
||||
filename_exn(name, "cannot open output file", filename, errv);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user