Commit 7ecc283b authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

msvcrt: Implemented stat64, wstat64 and fstat64.

Change all other variations of stat use the stat64 family, since it is the most general.
parent cbb6da2d
...@@ -111,19 +111,34 @@ static CRITICAL_SECTION MSVCRT_file_cs; ...@@ -111,19 +111,34 @@ static CRITICAL_SECTION MSVCRT_file_cs;
#define LOCK_FILES() do { EnterCriticalSection(&MSVCRT_file_cs); } while (0) #define LOCK_FILES() do { EnterCriticalSection(&MSVCRT_file_cs); } while (0)
#define UNLOCK_FILES() do { LeaveCriticalSection(&MSVCRT_file_cs); } while (0) #define UNLOCK_FILES() do { LeaveCriticalSection(&MSVCRT_file_cs); } while (0)
static void msvcrt_cp_from_stati64(const struct MSVCRT__stati64 *bufi64, struct MSVCRT__stat *buf) static void msvcrt_stat64_to_stat(const struct MSVCRT__stat64 *buf64, struct MSVCRT__stat *buf)
{ {
buf->st_dev = bufi64->st_dev; buf->st_dev = buf64->st_dev;
buf->st_ino = bufi64->st_ino; buf->st_ino = buf64->st_ino;
buf->st_mode = bufi64->st_mode; buf->st_mode = buf64->st_mode;
buf->st_nlink = bufi64->st_nlink; buf->st_nlink = buf64->st_nlink;
buf->st_uid = bufi64->st_uid; buf->st_uid = buf64->st_uid;
buf->st_gid = bufi64->st_gid; buf->st_gid = buf64->st_gid;
buf->st_rdev = bufi64->st_rdev; buf->st_rdev = buf64->st_rdev;
buf->st_size = bufi64->st_size; buf->st_size = buf64->st_size;
buf->st_atime = bufi64->st_atime; buf->st_atime = buf64->st_atime;
buf->st_mtime = bufi64->st_mtime; buf->st_mtime = buf64->st_mtime;
buf->st_ctime = bufi64->st_ctime; buf->st_ctime = buf64->st_ctime;
}
static void msvcrt_stat64_to_stati64(const struct MSVCRT__stat64 *buf64, struct MSVCRT__stati64 *buf)
{
buf->st_dev = buf64->st_dev;
buf->st_ino = buf64->st_ino;
buf->st_mode = buf64->st_mode;
buf->st_nlink = buf64->st_nlink;
buf->st_uid = buf64->st_uid;
buf->st_gid = buf64->st_gid;
buf->st_rdev = buf64->st_rdev;
buf->st_size = buf64->st_size;
buf->st_atime = buf64->st_atime;
buf->st_mtime = buf64->st_mtime;
buf->st_ctime = buf64->st_ctime;
} }
static inline BOOL msvcrt_is_valid_fd(int fd) static inline BOOL msvcrt_is_valid_fd(int fd)
...@@ -1106,9 +1121,9 @@ int CDECL MSVCRT__fileno(MSVCRT_FILE* file) ...@@ -1106,9 +1121,9 @@ int CDECL MSVCRT__fileno(MSVCRT_FILE* file)
} }
/********************************************************************* /*********************************************************************
* _fstati64 (MSVCRT.@) * _fstat64 (MSVCRT.@)
*/ */
int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf) int CDECL MSVCRT__fstat64(int fd, struct MSVCRT__stat64* buf)
{ {
DWORD dw; DWORD dw;
BY_HANDLE_FILE_INFORMATION hfi; BY_HANDLE_FILE_INFORMATION hfi;
...@@ -1126,7 +1141,7 @@ int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf) ...@@ -1126,7 +1141,7 @@ int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf)
} }
memset(&hfi, 0, sizeof(hfi)); memset(&hfi, 0, sizeof(hfi));
memset(buf, 0, sizeof(struct MSVCRT__stati64)); memset(buf, 0, sizeof(struct MSVCRT__stat64));
if (!GetFileInformationByHandle(hand, &hfi)) if (!GetFileInformationByHandle(hand, &hfi))
{ {
WARN(":failed-last error (%d)\n",GetLastError()); WARN(":failed-last error (%d)\n",GetLastError());
...@@ -1156,15 +1171,29 @@ int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf) ...@@ -1156,15 +1171,29 @@ int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf)
} }
/********************************************************************* /*********************************************************************
* _fstati64 (MSVCRT.@)
*/
int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf)
{
int ret;
struct MSVCRT__stat64 buf64;
ret = MSVCRT__fstat64(fd, &buf64);
if (!ret)
msvcrt_stat64_to_stati64(&buf64, buf);
return ret;
}
/*********************************************************************
* _fstat (MSVCRT.@) * _fstat (MSVCRT.@)
*/ */
int CDECL MSVCRT__fstat(int fd, struct MSVCRT__stat* buf) int CDECL MSVCRT__fstat(int fd, struct MSVCRT__stat* buf)
{ int ret; { int ret;
struct MSVCRT__stati64 bufi64; struct MSVCRT__stat64 buf64;
ret = MSVCRT__fstati64(fd, &bufi64); ret = MSVCRT__fstat64(fd, &buf64);
if (!ret) if (!ret)
msvcrt_cp_from_stati64(&bufi64, buf); msvcrt_stat64_to_stat(&buf64, buf);
return ret; return ret;
} }
...@@ -1692,9 +1721,9 @@ int CDECL _setmode(int fd,int mode) ...@@ -1692,9 +1721,9 @@ int CDECL _setmode(int fd,int mode)
} }
/********************************************************************* /*********************************************************************
* _stati64 (MSVCRT.@) * _stat64 (MSVCRT.@)
*/ */
int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) int CDECL MSVCRT__stat64(const char* path, struct MSVCRT__stat64 * buf)
{ {
DWORD dw; DWORD dw;
WIN32_FILE_ATTRIBUTE_DATA hfi; WIN32_FILE_ATTRIBUTE_DATA hfi;
...@@ -1710,7 +1739,7 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) ...@@ -1710,7 +1739,7 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf)
return -1; return -1;
} }
memset(buf,0,sizeof(struct MSVCRT__stati64)); memset(buf,0,sizeof(struct MSVCRT__stat64));
/* FIXME: rdev isn't drive num, despite what the docs say-what is it? /* FIXME: rdev isn't drive num, despite what the docs say-what is it?
Bon 011120: This FIXME seems incorrect Bon 011120: This FIXME seems incorrect
...@@ -1753,27 +1782,41 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) ...@@ -1753,27 +1782,41 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf)
buf->st_mtime = buf->st_ctime = dw; buf->st_mtime = buf->st_ctime = dw;
TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink, TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink,
(long)(buf->st_size >> 32),(long)buf->st_size, (long)(buf->st_size >> 32),(long)buf->st_size,
buf->st_atime,buf->st_mtime, buf->st_ctime); (long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime);
return 0; return 0;
} }
/********************************************************************* /*********************************************************************
* _stati64 (MSVCRT.@)
*/
int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf)
{
int ret;
struct MSVCRT__stat64 buf64;
ret = MSVCRT__stat64(path, &buf64);
if (!ret)
msvcrt_stat64_to_stati64(&buf64, buf);
return ret;
}
/*********************************************************************
* _stat (MSVCRT.@) * _stat (MSVCRT.@)
*/ */
int CDECL MSVCRT__stat(const char* path, struct MSVCRT__stat * buf) int CDECL MSVCRT__stat(const char* path, struct MSVCRT__stat * buf)
{ int ret; { int ret;
struct MSVCRT__stati64 bufi64; struct MSVCRT__stat64 buf64;
ret = MSVCRT__stati64( path, &bufi64); ret = MSVCRT__stat64( path, &buf64);
if (!ret) if (!ret)
msvcrt_cp_from_stati64(&bufi64, buf); msvcrt_stat64_to_stat(&buf64, buf);
return ret; return ret;
} }
/********************************************************************* /*********************************************************************
* _wstati64 (MSVCRT.@) * _wstat64 (MSVCRT.@)
*/ */
int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 * buf) int CDECL MSVCRT__wstat64(const MSVCRT_wchar_t* path, struct MSVCRT__stat64 * buf)
{ {
DWORD dw; DWORD dw;
WIN32_FILE_ATTRIBUTE_DATA hfi; WIN32_FILE_ATTRIBUTE_DATA hfi;
...@@ -1789,7 +1832,7 @@ int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 * ...@@ -1789,7 +1832,7 @@ int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 *
return -1; return -1;
} }
memset(buf,0,sizeof(struct MSVCRT__stat)); memset(buf,0,sizeof(struct MSVCRT__stat64));
/* FIXME: rdev isn't drive num, despite what the docs says-what is it? */ /* FIXME: rdev isn't drive num, despite what the docs says-what is it? */
if (MSVCRT_iswalpha(*path)) if (MSVCRT_iswalpha(*path))
...@@ -1828,20 +1871,34 @@ int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 * ...@@ -1828,20 +1871,34 @@ int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 *
buf->st_mtime = buf->st_ctime = dw; buf->st_mtime = buf->st_ctime = dw;
TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink, TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink,
(long)(buf->st_size >> 32),(long)buf->st_size, (long)(buf->st_size >> 32),(long)buf->st_size,
buf->st_atime,buf->st_mtime, buf->st_ctime); (long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime);
return 0; return 0;
} }
/********************************************************************* /*********************************************************************
* _wstati64 (MSVCRT.@)
*/
int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 * buf)
{
int ret;
struct MSVCRT__stat64 buf64;
ret = MSVCRT__wstat64(path, &buf64);
if (!ret)
msvcrt_stat64_to_stati64(&buf64, buf);
return ret;
}
/*********************************************************************
* _wstat (MSVCRT.@) * _wstat (MSVCRT.@)
*/ */
int CDECL MSVCRT__wstat(const MSVCRT_wchar_t* path, struct MSVCRT__stat * buf) int CDECL MSVCRT__wstat(const MSVCRT_wchar_t* path, struct MSVCRT__stat * buf)
{ {
int ret; int ret;
struct MSVCRT__stati64 bufi64; struct MSVCRT__stat64 buf64;
ret = MSVCRT__wstati64( path, &bufi64 ); ret = MSVCRT__wstat64( path, &buf64 );
if (!ret) msvcrt_cp_from_stati64(&bufi64, buf); if (!ret) msvcrt_stat64_to_stat(&buf64, buf);
return ret; return ret;
} }
......
...@@ -243,7 +243,7 @@ ...@@ -243,7 +243,7 @@
@ cdecl _fputwchar(long) @ cdecl _fputwchar(long)
@ cdecl _fsopen(str str long) MSVCRT__fsopen @ cdecl _fsopen(str str long) MSVCRT__fsopen
@ cdecl _fstat(long ptr) MSVCRT__fstat @ cdecl _fstat(long ptr) MSVCRT__fstat
@ stub _fstat64 @ cdecl _fstat64(long ptr) MSVCRT__fstat64
@ cdecl _fstati64(long ptr) MSVCRT__fstati64 @ cdecl _fstati64(long ptr) MSVCRT__fstati64
@ cdecl _ftime(ptr) @ cdecl _ftime(ptr)
@ cdecl -ret64 _ftol() ntdll._ftol @ cdecl -ret64 _ftol() ntdll._ftol
...@@ -451,7 +451,7 @@ ...@@ -451,7 +451,7 @@
@ cdecl _spawnvpe(long str ptr ptr) @ cdecl _spawnvpe(long str ptr ptr)
@ cdecl _splitpath(str ptr ptr ptr ptr) ntdll._splitpath @ cdecl _splitpath(str ptr ptr ptr ptr) ntdll._splitpath
@ cdecl _stat(str ptr) MSVCRT__stat @ cdecl _stat(str ptr) MSVCRT__stat
@ stub _stat64 @ cdecl _stat64(str ptr) MSVCRT__stat64
@ cdecl _stati64(str ptr) MSVCRT__stati64 @ cdecl _stati64(str ptr) MSVCRT__stati64
@ cdecl _statusfp() @ cdecl _statusfp()
@ cdecl _strcmpi(str str) ntdll._strcmpi @ cdecl _strcmpi(str str) ntdll._strcmpi
...@@ -560,6 +560,7 @@ ...@@ -560,6 +560,7 @@
@ cdecl _wsplitpath(wstr wstr wstr wstr wstr) @ cdecl _wsplitpath(wstr wstr wstr wstr wstr)
@ cdecl _wstat(wstr ptr) MSVCRT__wstat @ cdecl _wstat(wstr ptr) MSVCRT__wstat
@ cdecl _wstati64(wstr ptr) MSVCRT__wstati64 @ cdecl _wstati64(wstr ptr) MSVCRT__wstati64
@ cdecl _wstat64(wstr ptr) MSVCRT__wstat64
@ cdecl _wstrdate(ptr) @ cdecl _wstrdate(ptr)
@ cdecl _wstrtime(ptr) @ cdecl _wstrtime(ptr)
@ stub _wsystem #(wstr) @ stub _wsystem #(wstr)
......
...@@ -88,6 +88,7 @@ static void test_types(void) ...@@ -88,6 +88,7 @@ static void test_types(void)
CHECK_TYPE(_off_t); CHECK_TYPE(_off_t);
CHECK_TYPE(clock_t); CHECK_TYPE(clock_t);
CHECK_TYPE(time_t); CHECK_TYPE(time_t);
CHECK_TYPE(__time64_t);
CHECK_TYPE(fpos_t); CHECK_TYPE(fpos_t);
CHECK_SIZE(FILE); CHECK_SIZE(FILE);
CHECK_TYPE(terminate_handler); CHECK_TYPE(terminate_handler);
...@@ -295,6 +296,18 @@ static void test_structs(void) ...@@ -295,6 +296,18 @@ static void test_structs(void)
CHECK_FIELD(_stati64, st_atime); CHECK_FIELD(_stati64, st_atime);
CHECK_FIELD(_stati64, st_mtime); CHECK_FIELD(_stati64, st_mtime);
CHECK_FIELD(_stati64, st_ctime); CHECK_FIELD(_stati64, st_ctime);
CHECK_STRUCT(_stat64);
CHECK_FIELD(_stat64, st_dev);
CHECK_FIELD(_stat64, st_ino);
CHECK_FIELD(_stat64, st_mode);
CHECK_FIELD(_stat64, st_nlink);
CHECK_FIELD(_stat64, st_uid);
CHECK_FIELD(_stat64, st_gid);
CHECK_FIELD(_stat64, st_rdev);
CHECK_FIELD(_stat64, st_size);
CHECK_FIELD(_stat64, st_atime);
CHECK_FIELD(_stat64, st_mtime);
CHECK_FIELD(_stat64, st_ctime);
} }
/************* Checking defines ***************/ /************* Checking defines ***************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment