From e6cf4bd3a896c7b79fdf99d58311619159a50936 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Tue, 16 Feb 2021 22:12:30 -0500 Subject: [PATCH] ReplaceFileW w/ backup --- lightning-persister/src/util.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lightning-persister/src/util.rs b/lightning-persister/src/util.rs index 9dd9ddb9b..ac923d685 100644 --- a/lightning-persister/src/util.rs +++ b/lightning-persister/src/util.rs @@ -100,8 +100,9 @@ pub(crate) fn write_to_file(path: String, filename: String, da // path_to_windows_str(src).as_ptr(), path_to_windows_str(dst).as_ptr(), // winapi::um::winbase::MOVEFILE_WRITE_THROUGH | winapi::um::winbase::MOVEFILE_REPLACE_EXISTING // )}); + let backup_filepath = format!("{}.backup", filename_with_path.clone()); call!(unsafe {winapi::um::winbase::ReplaceFileW( - path_to_windows_str(src).as_ptr(), path_to_windows_str(dst).as_ptr(), std::ptr::null, + path_to_windows_str(src).as_ptr(), path_to_windows_str(dst).as_ptr(), path_to_windows_str(backup_filepath).as_ptr(), winapi::um::winbase::MOVEFILE_WRITE_THROUGH | winapi::um::winbase::MOVEFILE_REPLACE_EXISTING, std::ptr::null, std::ptr::null )}); println!("VMW: renamed"); -- 2.39.5