From 4d23e09fb252210736a5a0bbe3105d781cadce65 Mon Sep 17 00:00:00 2001 From: Borja Garcia Date: Sat, 8 Nov 2025 00:25:33 +0100 Subject: [PATCH] Add file existence check before processing Added a check to verify if the specified file exists and is readable before proceeding. --- src/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 071e9c8..aaaf383 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,6 +149,16 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } + // Check if file exists and is readable + { + std::ifstream file(args.bit_file); + if (!args.bit_file.empty() && !file.good()) { + printError("Error: cannot open file '" + args.bit_file + "'"); + return EXIT_FAILURE; + } + file.close(); + } + if (args.prg_type == Device::WR_SRAM) cout << "write to ram" << endl; if (args.prg_type == Device::WR_FLASH)