summaryrefslogtreecommitdiff
path: root/tbdiff-create/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tbdiff-create/main.c')
-rw-r--r--tbdiff-create/main.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/tbdiff-create/main.c b/tbdiff-create/main.c
index 79b35e2..462d39f 100644
--- a/tbdiff-create/main.c
+++ b/tbdiff-create/main.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdint.h>
+#include <fcntl.h>
#include <unistd.h>
#include <tbdiff/tbdiff.h>
@@ -62,15 +63,17 @@ main(int argc,
return EXIT_FAILURE;
}
- FILE *fp = fopen(argv[1], "wb");
- if(fp == NULL) {
- fprintf(stderr, "ERROR: Unable to open patch for writing.\n");
+ int fd = open(argv[1],
+ O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if(fd < 0) {
+ fprintf(stderr, "Error(%d): Unable to open patch for writing.\n", -fd);
return EXIT_FAILURE;
}
int err;
- if((err = tbd_create(fp, tstat[0], tstat[1])) != 0) {
- fclose(fp);
+ if((err = tbd_create(fd, tstat[0], tstat[1])) != 0) {
+ close(fd);
tbd_stat_free(tstat[0]);
tbd_stat_free(tstat[1]);
@@ -89,7 +92,7 @@ main(int argc,
return EXIT_FAILURE;
}
- fclose(fp);
+ close(fd);
tbd_stat_free(tstat[0]);
tbd_stat_free(tstat[1]);