From 7c9e074e8731efcd453da61d7aa2d7f68c587632 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 1 Feb 2022 13:18:21 -0500 Subject: Make xas_riff_file_new() always write header --- src/riff.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/riff.c b/src/riff.c index 77def32..b59c819 100644 --- a/src/riff.c +++ b/src/riff.c @@ -78,10 +78,9 @@ static xas_riff *file_new(const char *path, goto error_malloc_riff; } - riff->fd = (flags & O_CREAT)? open(path, flags, 0644): - open(path, flags); + flags |= O_CREAT; - if (riff->fd < 0) { + if ((riff->fd = open(path, flags, 0644)) < 0) { goto error_open; } @@ -90,10 +89,8 @@ static xas_riff *file_new(const char *path, riff->sample_rate = sample_rate; riff->channels = channels; - if (flags & (O_CREAT | O_TRUNC)) { - if (header_write(riff) < 0) { - goto error_header_write; - } + if (header_write(riff) < 0) { + goto error_header_write; } return riff; -- cgit v1.2.3