Hi, (rename-file "x" "y")
fails on Windows if "y" already exists. I think it would be better to have the same behavior as Unix (i.e. overwrite). The attached patch does that. Regards, Michele
From 57098c32ce1b02834b972924c85690653b2d4fb3 Mon Sep 17 00:00:00 2001 From: Michele La Monaca <[email protected]> Date: Mon, 18 Aug 2014 16:19:44 +0200 Subject: [PATCH] Fix rename-file behavior on Windows when destination exists --- chicken.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chicken.h b/chicken.h index fc40303..0624e22 100644 --- a/chicken.h +++ b/chicken.h @@ -1309,7 +1309,12 @@ extern double trunc(double); #define C_string_compare(to, from, n) C_fix(C_memcmp(C_c_string(to), C_c_string(from), C_unfix(n))) #define C_string_compare_case_insensitive(from, to, n) \ C_fix(C_memcasecmp(C_c_string(from), C_c_string(to), C_unfix(n))) -#define C_rename_file(old, new) C_fix(rename(C_c_string(old), C_c_string(new))) +#if defined(_WIN32) || defined(_WIN64) +# include <windows.h> +# define C_rename_file(old, new) C_fix(0 == MoveFileEx(C_c_string(old), C_c_string(new), MOVEFILE_REPLACE_EXISTING) ? -1 : 0) +#else +# define C_rename_file(old, new) C_fix(rename(C_c_string(old), C_c_string(new))) +#endif #define C_delete_file(fname) C_fix(remove(C_c_string(fname))) #define C_poke_double(b, i, n) (((double *)C_data_pointer(b))[ C_unfix(i) ] = C_c_double(n), C_SCHEME_UNDEFINED) #define C_poke_c_string(b, i, from, s) (C_strlcpy((char *)C_block_item(b, C_unfix(i)), C_data_pointer(from), s), C_SCHEME_UNDEFINED) -- 1.8.4.3
_______________________________________________ Chicken-hackers mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-hackers
