gbasm: truncate file at end of output

When overwriting an old output file, this will delete the extra data
if the new output is shorter than the old output.
This commit is contained in:
2017-05-23 22:12:22 -07:00
parent 4cad9a3ec3
commit 05bff5cefb

View File

@@ -39,7 +39,7 @@ int main(int argc, char **argv)
close(out_fd); close(out_fd);
} }
out_fd = open(optarg, O_WRONLY | O_CREAT); out_fd = open(optarg, O_WRONLY | O_CREAT | O_TRUNC);
if (out_fd < 0) { if (out_fd < 0) {
fprintf(stderr, "failed to open output file %s\n", optarg); fprintf(stderr, "failed to open output file %s\n", optarg);
exit(1); exit(1);