Skip to content

Commit 724fee8

Browse files
committed
support r+b for io.open
1 parent cd6663a commit 724fee8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/xmake/io/file_open.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,14 @@ tb_int_t xm_io_file_open(lua_State* lua)
192192
case 'r': default: mode = TB_FILE_MODE_RO; break;
193193
}
194194

195+
// update file?
196+
tb_bool_t update = !!tb_strchr(modestr, '+');
197+
if (update && mode == TB_FILE_MODE_RO)
198+
mode = TB_FILE_MODE_RW;
199+
195200
// get file encoding
196201
tb_long_t bomoff = 0;
197202
tb_stream_ref_t stream = tb_null;
198-
tb_bool_t update = !!tb_strchr(modestr, '+');
199203
tb_size_t encoding = XM_IO_FILE_ENCODING_UNKNOWN;
200204
if (modestr[1] == 'b' || (update && modestr[2] == 'b'))
201205
encoding = XM_IO_FILE_ENCODING_BINARY;

0 commit comments

Comments
 (0)