app/rom_to_file: catch Node_already_exists and overwrite files

Ref #1934
This commit is contained in:
Emery Hemingway 2017-04-10 00:59:32 -05:00 committed by Christian Helmuth
parent 6106e64aac
commit 29b3fff5eb

View File

@ -124,7 +124,11 @@ void Rom_to_file::Main::_handle_update()
Handle_guard dir_guard(_fs, dir_handle);
File_handle handle;
handle = _fs.file(dir_handle, file_name, File_system::WRITE_ONLY, true);
try {
handle = _fs.file(dir_handle, file_name, File_system::WRITE_ONLY, true);
} catch (Node_already_exists) {
handle = _fs.file(dir_handle, file_name, File_system::WRITE_ONLY, false);
}
_fs.truncate(handle, 0);
@ -136,6 +140,7 @@ void Rom_to_file::Main::_handle_update()
}
_fs.close(handle);
} catch (Permission_denied) {
error(Cstring(dir_path), file_name, ": permission denied");