mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 12:14:32 +00:00
[CRT] Various fixes to Wine file functions.
Import the following Wine commits: * ea2798f1ce9 Iván Matellanes: msvcrt: _setmode should check if file descriptor is valid. * 9b495caacfd Carlo Bramini: msvcrt: Call SetFilePointer() with correct parameters. * 13f34481b26 Carlo Bramini: msvcrt: Use MSVCRT_xxx macros instead of the same ones from GLIBC. * 781b069ed81 Piotr Caban: msvcrt: Don't close HANDLE if stdout or stderr is sharing it.
This commit is contained in:
parent
6aa8e3cc20
commit
2765bddffa
1 changed files with 14 additions and 1 deletions
|
@ -936,6 +936,14 @@ int CDECL _close(int fd)
|
||||||
TRACE(":fd (%d) handle (%p)\n", fd, info->handle);
|
TRACE(":fd (%d) handle (%p)\n", fd, info->handle);
|
||||||
if (!(info->wxflag & WX_OPEN)) {
|
if (!(info->wxflag & WX_OPEN)) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
} else if (fd == STDOUT_FILENO &&
|
||||||
|
info->handle == get_ioinfo_nolock(STDERR_FILENO)->handle) {
|
||||||
|
msvcrt_free_fd(fd);
|
||||||
|
ret = 0;
|
||||||
|
} else if (fd == STDERR_FILENO &&
|
||||||
|
info->handle == get_ioinfo_nolock(STDOUT_FILENO)->handle) {
|
||||||
|
msvcrt_free_fd(fd);
|
||||||
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
ret = CloseHandle(info->handle) ? 0 : -1;
|
ret = CloseHandle(info->handle) ? 0 : -1;
|
||||||
msvcrt_free_fd(fd);
|
msvcrt_free_fd(fd);
|
||||||
|
@ -1237,7 +1245,7 @@ int CDECL _locking(int fd, int mode, LONG nbytes)
|
||||||
(mode==_LK_NBRLCK)?"_LK_NBRLCK":
|
(mode==_LK_NBRLCK)?"_LK_NBRLCK":
|
||||||
"UNKNOWN");
|
"UNKNOWN");
|
||||||
|
|
||||||
if ((cur_locn = SetFilePointer(info->handle, 0L, NULL, SEEK_CUR)) == INVALID_SET_FILE_POINTER)
|
if ((cur_locn = SetFilePointer(info->handle, 0L, NULL, FILE_CURRENT)) == INVALID_SET_FILE_POINTER)
|
||||||
{
|
{
|
||||||
release_ioinfo(info);
|
release_ioinfo(info);
|
||||||
FIXME ("Seek failed\n");
|
FIXME ("Seek failed\n");
|
||||||
|
@ -2480,6 +2488,11 @@ int CDECL _setmode(int fd,int mode)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(info == &__badioinfo) {
|
||||||
|
*_errno() = EBADF;
|
||||||
|
return EOF;
|
||||||
|
}
|
||||||
|
|
||||||
if(mode == _O_BINARY) {
|
if(mode == _O_BINARY) {
|
||||||
info->wxflag &= ~WX_TEXT;
|
info->wxflag &= ~WX_TEXT;
|
||||||
info->exflag &= ~(EF_UTF8|EF_UTF16);
|
info->exflag &= ~(EF_UTF8|EF_UTF16);
|
||||||
|
|
Loading…
Reference in a new issue