From 86095bcaa8c54177b10afdb5bf40beacff707dd8 Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Thu, 11 Apr 2019 14:21:14 +0100 Subject: [PATCH] Document rename_replace_existing macro --- library/psa_its_file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/psa_its_file.c b/library/psa_its_file.c index bc0f84cae..8cdf783a7 100644 --- a/library/psa_its_file.c +++ b/library/psa_its_file.c @@ -62,9 +62,12 @@ #define PSA_ITS_MAGIC_STRING "PSA\0ITS\0" #define PSA_ITS_MAGIC_LENGTH 8 +/* As rename fails on Windows if the new filepath already exists, + * use MoveFileExA with the MOVEFILE_REPLACE_EXISTING flag instead. + * Returns 0 on success, nonzero on failure. */ #if defined(_WIN32) #define rename_replace_existing( oldpath, newpath ) \ - (!MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING )) + ( ! MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING ) ) #else #define rename_replace_existing( oldpath, newpath ) rename( oldpath, newpath ) #endif