Skip to content

Commit 61e1c53

Browse files
committed
fix windwos build
1 parent 3329a5d commit 61e1c53

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/file_stream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ int file_stream_open(struct file_stream *stream, const char *path, int flags,
8383
((flags & O_TRUNC) ? CREATE_ALWAYS : OPEN_ALWAYS) : OPEN_EXISTING;
8484
}
8585

86-
if (flags & O_TRUNC)
86+
/* O_TRUNC without O_CREAT means truncate existing file */
87+
if ((flags & O_TRUNC) && !(flags & O_CREAT))
8788
creation_disposition = TRUNCATE_EXISTING;
8889

8990
stream->handle = CreateFileA(path, desired_access, share_mode,

0 commit comments

Comments
 (0)