Merge pull request #1 from debuti/Bit-file-validation

Add file existence check before processing
This commit is contained in:
Borja Garcia 2025-11-08 00:26:22 +01:00 committed by GitHub
commit b6df4b8699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -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)