diff options
author | Ian Moffett <ian@osmora.org> | 2025-04-09 00:48:39 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-04-09 00:48:39 -0400 |
commit | 608ea586537ab56a7c7ff2afb989ec6a4e604787 (patch) | |
tree | 4d3ddcbde980bba04c4c17f429d6a14d61717e93 | |
parent | a45aca4371aec89abb42b785580c3e5e2df870a0 (diff) |
file: Allow flags to be passed
Signed-off-by: Ian Moffett <ian@osmora.org>
-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_ */ |