1 #include <msvcrt/stdio.h>
2 #include <msvcrt/internal/file.h>
4 FILE * __alloc_file(void);
6 FILE *_fdopen(int handle
, char *mode
)
26 file
= __alloc_file();
31 rw
= (mode
[1] == '+') || (mode
[1] && (mode
[2] == '+'));
34 _lseek(handle
, 0, SEEK_END
);
40 // The mode of the stream must be compatible with the mode of the file descriptor.
41 // this should be checked.
44 file
->_flag
= _IOREAD
| _IOWRT
;
45 else if (*mode
== 'r')
46 file
->_flag
= _IOREAD
;
50 file
->_base
= file
->_ptr
= NULL
;
55 FILE *_wfdopen(int handle
, wchar_t *mode
)
75 file
= __alloc_file();
80 rw
= (mode
[1] == L
'+') || (mode
[1] && (mode
[2] == L
'+'));
83 _lseek(handle
, 0, SEEK_END
);
89 // The mode of the stream must be compatible with the mode of the file descriptor.
90 // this should be checked.
93 file
->_flag
= _IOREAD
| _IOWRT
;
94 else if (*mode
== L
'r')
95 file
->_flag
= _IOREAD
;
99 file
->_base
= file
->_ptr
= NULL
;