mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 06:12:27 +00:00
parent
ce9aeb2aed
commit
1df4296208
3 changed files with 19 additions and 9 deletions
|
@ -17,9 +17,11 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/stdio/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
|
@ -33,9 +35,12 @@
|
|||
*/
|
||||
FILE *fdopen(int fd, const char *mode) {
|
||||
FILE *f;
|
||||
struct stat st;
|
||||
if (fstat(fd, &st))
|
||||
return 0;
|
||||
if ((f = __stdio_alloc())) {
|
||||
f->fd = fd;
|
||||
f->bufmode = ischardev(fd) ? _IOLBF : _IOFBF;
|
||||
f->bufmode = S_ISREG(st.st_mode) ? _IOFBF : _IONBF;
|
||||
f->iomode = fopenflags(mode);
|
||||
f->buf = f->mem;
|
||||
f->size = BUFSIZ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue