From 7f02627290cedf2d5ef6b45cddc6117c763cb15b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 13 Jun 2016 10:10:50 -0300 Subject: -Add visible IO errors when closing a file fails due to it being locked (most likely on windows), closes #4760 --- drivers/unix/file_access_unix.cpp | 5 +++++ drivers/windows/file_access_windows.cpp | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 9f24633bd4..2838e7d913 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -124,6 +124,11 @@ void FileAccessUnix::close() { //unlink(save_path.utf8().get_data()); //print_line("renaming.."); int rename_error = rename((save_path+".tmp").utf8().get_data(),save_path.utf8().get_data()); + + if (rename_error && close_fail_notify) { + close_fail_notify(save_path); + } + save_path=""; ERR_FAIL_COND( rename_error != 0); } diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 66181a6f44..3f27068fb2 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -131,6 +131,10 @@ void FileAccessWindows::close() { //atomic replace for existing file rename_error = !ReplaceFileW(save_path.c_str(), (save_path+".tmp").c_str(), NULL, 2|4, NULL, NULL); } + if (rename_error && close_fail_notify) { + close_fail_notify(save_path); + } + save_path=""; ERR_FAIL_COND( rename_error ); } -- cgit v1.2.3