#include <precomp.h>
#include "wine/unicode.h"
+#include "internal/wine/msvcrt.h"
#include <sys/utime.h>
#include <direct.h>
#define MSVCRT_INTERNAL_BUFSIZ 4096
-/* ioinfo structure size is different in msvcrXX.dll's */
-typedef struct {
- HANDLE handle;
- unsigned char wxflag;
- char lookahead[3];
- int exflag;
- CRITICAL_SECTION crit;
-} ioinfo;
-
/*********************************************************************
* __pioinfo (MSVCRT.@)
* array of pointers to ioinfo arrays [32]
return ret + (fd%MSVCRT_FD_BLOCK_SIZE);
}
-static inline ioinfo* get_ioinfo(int fd)
+/*static*/ inline ioinfo* get_ioinfo(int fd)
{
ioinfo *ret = get_ioinfo_nolock(fd);
if(ret->exflag & EF_CRIT_INIT)
return ret;
}
-static inline void release_ioinfo(ioinfo *info)
+/*static*/ inline void release_ioinfo(ioinfo *info)
{
if(info->exflag & EF_CRIT_INIT)
LeaveCriticalSection(&info->crit);
#include <precomp.h>
#include <tchar.h>
#include <direct.h>
+#include <internal/wine/msvcrt.h>
-HANDLE fdtoh(int fd);
+inline ioinfo* get_ioinfo(int fd);
+inline void release_ioinfo(ioinfo *info);
#define ALL_S_IREAD (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
#define ALL_S_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
int CDECL _fstat64(int fd, struct __stat64* buf)
{
+ ioinfo *info = get_ioinfo(fd);
DWORD dw;
DWORD type;
BY_HANDLE_FILE_INFORMATION hfi;
- HANDLE hand = fdtoh(fd);
- TRACE(":fd (%d) stat (%p)\n",fd,buf);
- if (hand == INVALID_HANDLE_VALUE)
+ TRACE(":fd (%d) stat (%p)\n", fd, buf);
+ if (info->handle == INVALID_HANDLE_VALUE)
+ {
+ release_ioinfo(info);
return -1;
+ }
if (!buf)
{
WARN(":failed-NULL buf\n");
_dosmaperr(ERROR_INVALID_PARAMETER);
+ release_ioinfo(info);
return -1;
}
memset(&hfi, 0, sizeof(hfi));
memset(buf, 0, sizeof(struct __stat64));
- type = GetFileType(hand);
+ type = GetFileType(info->handle);
if (type == FILE_TYPE_PIPE)
{
buf->st_dev = buf->st_rdev = fd;
}
else /* FILE_TYPE_DISK etc. */
{
- if (!GetFileInformationByHandle(hand, &hfi))
+ if (!GetFileInformationByHandle(info->handle, &hfi))
{
WARN(":failed-last error (%d)\n",GetLastError());
_dosmaperr(ERROR_INVALID_PARAMETER);
+ release_ioinfo(info);
return -1;
}
buf->st_mode = _S_IFREG | ALL_S_IREAD;
}
TRACE(":dwFileAttributes = 0x%x, mode set to 0x%x\n",hfi.dwFileAttributes,
buf->st_mode);
+ release_ioinfo(info);
return 0;
}
#include <time.h>
#include <sys/utime.h>
#include "bitsfixup.h"
+#include <internal/wine/msvcrt.h>
-HANDLE fdtoh(int fd);
+inline ioinfo* get_ioinfo(int fd);
+inline void release_ioinfo(ioinfo *info);
/******************************************************************************
* \name _futime
int
_futime(int fd, struct _utimbuf *filetime)
{
- HANDLE handle;
+ ioinfo *info = get_ioinfo(fd);
FILETIME at, wt;
- handle = fdtoh(fd);
- if (handle == INVALID_HANDLE_VALUE)
+ if (info->handle == INVALID_HANDLE_VALUE)
{
+ release_ioinfo(info);
return -1;
}
}
}
- if (!SetFileTime(handle, NULL, &at, &wt))
+ if (!SetFileTime(info->handle, NULL, &at, &wt))
{
+ release_ioinfo(info);
_dosmaperr(GetLastError());
return -1 ;
}
-
+ release_ioinfo(info);
return 0;
}