From ae0abdc4d0864ea36d120ca22df95548d2ecda44 Mon Sep 17 00:00:00 2001 From: Jonas Häggqvist Date: Sat, 21 May 2005 13:50:14 +0000 Subject: Check if the file could be modified, error if not. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6501 a1c6a512-1295-4272-9138-f99709370657 --- tools/fwpatcher/main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/fwpatcher/main.c b/tools/fwpatcher/main.c index 9c005fdad4..7f2eda8fd3 100644 --- a/tools/fwpatcher/main.c +++ b/tools/fwpatcher/main.c @@ -231,12 +231,21 @@ int PatchFirmware() } for (i = 0; i < sizeof(checksums)/sizeof(char *); ++i) { if (strncmp(checksums[i], md5sum_str, 32) == 0) { - /* all is fine, rename the patched file to original name of the firmware */ - MoveFileEx(name3, fn, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING); /* delete temp files */ DeleteFile(name1); DeleteFile(name2); - return 1; + /* all is fine, rename the patched file to original name of the firmware */ + if (MoveFileEx(name3, fn, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) { + return 1; + } + else { + DeleteFile(name3); /* Deleting a perfectly good firmware here really */ + MessageBox(NULL, + TEXT("Couldn't modify existing file.\n") + TEXT("Check if file is write protected, then try again."), + TEXT("Error"), MB_ICONERROR); + return 0; + } } } MessageBox(NULL, -- cgit