diff options
-rw-r--r-- | src/file.c | 11 | ||||
-rw-r--r-- | src/include/ldo/file.h | 3 |
2 files changed, 11 insertions, 3 deletions
@@ -34,8 +34,15 @@ #include <stdio.h> #include <ldo/file.h> +/* + * Open a file and return an LDO file + * handle. + * + * @filename: Path of file. + * @flags: O_* + */ struct ldo_file * -ldo_open(const char *filename) +ldo_open(const char *filename, int flags) { struct stat sb; struct ldo_file *lfp = NULL; @@ -54,7 +61,7 @@ ldo_open(const char *filename) return NULL; } - if ((retval = open(filename, O_RDWR)) < 0) { + if ((retval = open(filename, flags)) < 0) { fprintf(stderr, "failed to open %s\n", filename); perror("open"); free(lfp); diff --git a/src/include/ldo/file.h b/src/include/ldo/file.h index 6a743b8..1b82b7b 100644 --- a/src/include/ldo/file.h +++ b/src/include/ldo/file.h @@ -31,6 +31,7 @@ #define LDO_FILE_H_ #include <ldo/buffer.h> +#include <fcntl.h> struct ldo_file { int fd; @@ -38,7 +39,7 @@ struct ldo_file { struct ldo_buffer *data; }; -struct ldo_file *ldo_open(const char *filename); +struct ldo_file *ldo_open(const char *filename, int flags); void ldo_close(struct ldo_file *lfp); #endif /* !LDO_FILE_H_ */ |