ref: d87fa0118280aed3abcb02722a97283c9a881722
parent: 445836a9f06f302ab39aab4d2d1d943656db175d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Mar 19 22:56:16 EDT 2025
ios: add "writeonly" field
--- a/src/ios.c
+++ b/src/ios.c
@@ -656,6 +656,11 @@
static usize
ios_copy_(sl_ios *to, sl_ios *from, usize nbytes, bool all)
{
+ // FIXME(sigrid): ios doesn't really care about errors
+ // this needs a big fix everywhere
+ if(to->readonly || from->writeonly)
+ return 0;
+
usize total = 0, avail;
if(!ios_eof(from)){
do{
@@ -761,8 +766,10 @@
s = ios_fd(s, fd, 1, 1);
if(fd < 0)
goto open_file_err;
- if(!wr)
+ if(!wr && rd)
s->readonly = true;
+ if(wr && !rd)
+ s->writeonly = true;
s->loc.filename = MEM_STRDUP(fname);
return s;
open_file_err:
--- a/src/ios.h
+++ b/src/ios.h
@@ -43,6 +43,7 @@
int fd;
bool readonly;
+ bool writeonly;
bool ownbuf;
bool ownfd;
bool _eof;