diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 952f64c94e4..b55d600a2a7 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -111,19 +111,34 @@ static CRITICAL_SECTION MSVCRT_file_cs; #define LOCK_FILES() do { EnterCriticalSection(&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_ino = bufi64->st_ino; - buf->st_mode = bufi64->st_mode; - buf->st_nlink = bufi64->st_nlink; - buf->st_uid = bufi64->st_uid; - buf->st_gid = bufi64->st_gid; - buf->st_rdev = bufi64->st_rdev; - buf->st_size = bufi64->st_size; - buf->st_atime = bufi64->st_atime; - buf->st_mtime = bufi64->st_mtime; - buf->st_ctime = bufi64->st_ctime; + 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 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) @@ -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; BY_HANDLE_FILE_INFORMATION hfi; @@ -1126,7 +1141,7 @@ int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf) } memset(&hfi, 0, sizeof(hfi)); - memset(buf, 0, sizeof(struct MSVCRT__stati64)); + memset(buf, 0, sizeof(struct MSVCRT__stat64)); if (!GetFileInformationByHandle(hand, &hfi)) { WARN(":failed-last error (%d)\n",GetLastError()); @@ -1155,16 +1170,30 @@ int CDECL MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf) return 0; } +/********************************************************************* + * _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.@) */ int CDECL MSVCRT__fstat(int fd, struct MSVCRT__stat* buf) { int ret; - struct MSVCRT__stati64 bufi64; + struct MSVCRT__stat64 buf64; - ret = MSVCRT__fstati64(fd, &bufi64); + ret = MSVCRT__fstat64(fd, &buf64); if (!ret) - msvcrt_cp_from_stati64(&bufi64, buf); + msvcrt_stat64_to_stat(&buf64, buf); return ret; } @@ -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; WIN32_FILE_ATTRIBUTE_DATA hfi; @@ -1710,7 +1739,7 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) 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? Bon 011120: This FIXME seems incorrect @@ -1753,27 +1782,41 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) buf->st_mtime = buf->st_ctime = dw; 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, - buf->st_atime,buf->st_mtime, buf->st_ctime); + (long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime); 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.@) */ int CDECL MSVCRT__stat(const char* path, struct MSVCRT__stat * buf) { int ret; - struct MSVCRT__stati64 bufi64; + struct MSVCRT__stat64 buf64; - ret = MSVCRT__stati64( path, &bufi64); + ret = MSVCRT__stat64( path, &buf64); if (!ret) - msvcrt_cp_from_stati64(&bufi64, buf); + msvcrt_stat64_to_stat(&buf64, buf); 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; WIN32_FILE_ATTRIBUTE_DATA hfi; @@ -1789,7 +1832,7 @@ int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 * 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? */ if (MSVCRT_iswalpha(*path)) @@ -1828,20 +1871,34 @@ int CDECL MSVCRT__wstati64(const MSVCRT_wchar_t* path, struct MSVCRT__stati64 * buf->st_mtime = buf->st_ctime = dw; 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, - buf->st_atime,buf->st_mtime, buf->st_ctime); + (long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime); 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.@) */ int CDECL MSVCRT__wstat(const MSVCRT_wchar_t* path, struct MSVCRT__stat * buf) { int ret; - struct MSVCRT__stati64 bufi64; + struct MSVCRT__stat64 buf64; - ret = MSVCRT__wstati64( path, &bufi64 ); - if (!ret) msvcrt_cp_from_stati64(&bufi64, buf); + ret = MSVCRT__wstat64( path, &buf64 ); + if (!ret) msvcrt_stat64_to_stat(&buf64, buf); return ret; } diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 8c5b88ee70c..3ea78032ffb 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -243,7 +243,7 @@ @ cdecl _fputwchar(long) @ cdecl _fsopen(str str long) MSVCRT__fsopen @ cdecl _fstat(long ptr) MSVCRT__fstat -@ stub _fstat64 +@ cdecl _fstat64(long ptr) MSVCRT__fstat64 @ cdecl _fstati64(long ptr) MSVCRT__fstati64 @ cdecl _ftime(ptr) @ cdecl -ret64 _ftol() ntdll._ftol @@ -451,7 +451,7 @@ @ cdecl _spawnvpe(long str ptr ptr) @ cdecl _splitpath(str ptr ptr ptr ptr) ntdll._splitpath @ cdecl _stat(str ptr) MSVCRT__stat -@ stub _stat64 +@ cdecl _stat64(str ptr) MSVCRT__stat64 @ cdecl _stati64(str ptr) MSVCRT__stati64 @ cdecl _statusfp() @ cdecl _strcmpi(str str) ntdll._strcmpi @@ -560,6 +560,7 @@ @ cdecl _wsplitpath(wstr wstr wstr wstr wstr) @ cdecl _wstat(wstr ptr) MSVCRT__wstat @ cdecl _wstati64(wstr ptr) MSVCRT__wstati64 +@ cdecl _wstat64(wstr ptr) MSVCRT__wstat64 @ cdecl _wstrdate(ptr) @ cdecl _wstrtime(ptr) @ stub _wsystem #(wstr) diff --git a/dlls/msvcrt/tests/headers.c b/dlls/msvcrt/tests/headers.c index d5efa86aaf9..d7c7cd7f0c4 100644 --- a/dlls/msvcrt/tests/headers.c +++ b/dlls/msvcrt/tests/headers.c @@ -88,6 +88,7 @@ static void test_types(void) CHECK_TYPE(_off_t); CHECK_TYPE(clock_t); CHECK_TYPE(time_t); + CHECK_TYPE(__time64_t); CHECK_TYPE(fpos_t); CHECK_SIZE(FILE); CHECK_TYPE(terminate_handler); @@ -295,6 +296,18 @@ static void test_structs(void) CHECK_FIELD(_stati64, st_atime); CHECK_FIELD(_stati64, st_mtime); 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 ***************/