use fileutils to write memory dump

This commit is contained in:
Martijn Plak 2024-01-22 18:16:27 +01:00
parent 974713a4d8
commit de91e850b4

View file

@ -683,17 +683,13 @@ static int dumpmem_to_file(const char *filename, uint32_t addr, uint32_t len, bo
} }
if (res == PM3_SUCCESS) { if (res == PM3_SUCCESS) {
FILE *fd = fopen(filename, "wb"); PrintAndLogEx(INFO, "saving to "_YELLOW_("%s"), filename);
if (!fd) { if (saveFile(filename, ".bin", buffer, read) != 0) {
PrintAndLogEx(ERR, _RED_("Could not open file") " %s >>> ", filename); PrintAndLogEx(ERR, "error writing to file "_YELLOW_("%s"), filename);
res = PM3_EFILE; res = PM3_EFILE;
goto fail2;
} }
fwrite(buffer, 1, read, fd);
fclose(fd);
} }
fail2:
free(buffer); free(buffer);
fail: fail:
return res; return res;