2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/msvcrt/stdio/fsopen.c
5 * PURPOSE: Checks for keyboard hits
10 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
22 FILE* _tfsopen(const _TCHAR
*file
, const _TCHAR
*mode
, int shflag
)
25 int fd
, rw
, oflags
= 0;
39 rw
= (mode
[1] == '+') || (mode
[1] && (mode
[2] == '+'));
44 oflags
= O_CREAT
| (rw
? O_RDWR
: O_WRONLY
);
47 oflags
= rw
? O_RDWR
: O_RDONLY
;
50 oflags
= O_TRUNC
| O_CREAT
| (rw
? O_RDWR
: O_WRONLY
);
61 else if (tbchar
== 'b')
64 oflags
|= (_fmode
& (O_TEXT
|O_BINARY
));
66 if ( shflag
== _SH_DENYNO
)
67 shf
= _S_IREAD
| _S_IWRITE
;
68 else if( shflag
== _SH_DENYRD
)
70 else if( shflag
== _SH_DENYRW
)
72 else if( shflag
== _SH_DENYWR
)
75 shf
= _S_IREAD
| _S_IWRITE
;
77 fd
= _topen(file
, oflags
, shf
);
81 // msvcrt ensures that writes will end up at the end of file in append mode
82 // we just move the file pointer to the end of file initially
84 _lseek(fd
, 0, SEEK_END
);
90 f
->_flag
= _IOREAD
| _IOWRT
;
91 else if (*mode
== 'r')
96 f
->_base
= f
->_ptr
= NULL
;