From 29b3fff5eb6feaa7c2531017771e320efef44015 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 10 Apr 2017 00:59:32 -0500 Subject: [PATCH] app/rom_to_file: catch Node_already_exists and overwrite files Ref #1934 --- repos/os/src/app/rom_to_file/main.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repos/os/src/app/rom_to_file/main.cc b/repos/os/src/app/rom_to_file/main.cc index cc9b9b7ad0..542a454335 100644 --- a/repos/os/src/app/rom_to_file/main.cc +++ b/repos/os/src/app/rom_to_file/main.cc @@ -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");