From 89cdef0859259fdea0165b0d3918777d1ed42955 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 12 Jun 2023 23:17:49 +0200 Subject: libsquashfs: Add sqfs_open_native_file function Having a function to interpret the flags and open a native file handle simplifies the istream/ostream/file code which shares that decoding part, particularly on windows where the character set needs to be transformed. Signed-off-by: David Oberhollenzer --- lib/io/src/unix/ostream.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/io/src/unix/ostream.c') diff --git a/lib/io/src/unix/ostream.c b/lib/io/src/unix/ostream.c index 0e95167..52a566a 100644 --- a/lib/io/src/unix/ostream.c +++ b/lib/io/src/unix/ostream.c @@ -177,13 +177,12 @@ fail_free: sqfs_ostream_t *ostream_open_file(const char *path, int flags) { + sqfs_file_handle_t fd; sqfs_ostream_t *out; - int fd; - if (flags & SQFS_FILE_OPEN_OVERWRITE) { - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - } else { - fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0644); + if (sqfs_open_native_file(&fd, path, flags)) { + perror(path); + return NULL; } out = ostream_open_handle(path, fd, flags); -- cgit v1.2.3