summaryrefslogtreecommitdiffstats
path: root/tools/fwpatcher
diff options
context:
space:
mode:
authorJonas Häggqvist <rasher@rasher.dk>2005-05-21 13:50:14 +0000
committerJonas Häggqvist <rasher@rasher.dk>2005-05-21 13:50:14 +0000
commitae0abdc4d0864ea36d120ca22df95548d2ecda44 (patch)
treec2c7422879b10f0e70c33883b6b31f0e4def1520 /tools/fwpatcher
parent15379c792c0506f20da16c026bf2e281ddc48443 (diff)
downloadrockbox-ae0abdc4d0864ea36d120ca22df95548d2ecda44.tar.gz
rockbox-ae0abdc4d0864ea36d120ca22df95548d2ecda44.tar.bz2
rockbox-ae0abdc4d0864ea36d120ca22df95548d2ecda44.zip
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
Diffstat (limited to 'tools/fwpatcher')
-rw-r--r--tools/fwpatcher/main.c15
1 files changed, 12 insertions, 3 deletions
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,