From: Piotr Caban piotr@codeweavers.com
--- dlls/msvcrt/dir.c | 52 ++++++++++---------------------------- dlls/ucrtbase/tests/file.c | 6 +++++ 2 files changed, 20 insertions(+), 38 deletions(-)
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c index f5d95f1217e..b72682db806 100644 --- a/dlls/msvcrt/dir.c +++ b/dlls/msvcrt/dir.c @@ -137,26 +137,6 @@ static void msvcrt_fttofdi64( const WIN32_FIND_DATAA *fd, struct _finddatai64_t* strcpy(ft->name, fd->cFileName); }
-/* INTERNAL: Translate WIN32_FIND_DATAA to finddata64_t */ -static void msvcrt_fttofd64( const WIN32_FIND_DATAA *fd, struct _finddata64_t* ft) -{ - DWORD dw; - - if (fd->dwFileAttributes == FILE_ATTRIBUTE_NORMAL) - ft->attrib = 0; - else - ft->attrib = fd->dwFileAttributes; - - RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftCreationTime, &dw ); - ft->time_create = dw; - RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastAccessTime, &dw ); - ft->time_access = dw; - RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastWriteTime, &dw ); - ft->time_write = dw; - ft->size = ((__int64)fd->nFileSizeHigh) << 32 | fd->nFileSizeLow; - strcpy(ft->name, fd->cFileName); -} - /* INTERNAL: Translate WIN32_FIND_DATAW to wfinddata64_t */ static void msvcrt_wfttofd64( const WIN32_FIND_DATAW *fd, struct _wfinddata64_t* ft) { @@ -667,41 +647,37 @@ int CDECL _findnexti64(intptr_t hand, struct _finddatai64_t * ft) }
/********************************************************************* - * _findnext64 (MSVCRT.@) + * _wfindnext64 (MSVCRT.@) * - * 64-bit version of _findnext. + * Unicode version of _wfindnext64. */ -int CDECL _findnext64(intptr_t hand, struct _finddata64_t * ft) +int CDECL _wfindnext64(intptr_t hand, struct _wfinddata64_t * ft) { - WIN32_FIND_DATAA find_data; + WIN32_FIND_DATAW find_data;
- if (!FindNextFileA((HANDLE)hand, &find_data)) + if (!FindNextFileW((HANDLE)hand, &find_data)) { *_errno() = ENOENT; return -1; }
- msvcrt_fttofd64(&find_data,ft); + msvcrt_wfttofd64(&find_data,ft); return 0; }
/********************************************************************* - * _wfindnext64 (MSVCRT.@) + * _findnext64 (MSVCRT.@) * - * Unicode version of _wfindnext64. + * 64-bit version of _findnext. */ -int CDECL _wfindnext64(intptr_t hand, struct _wfinddata64_t * ft) +int CDECL _findnext64(intptr_t hand, struct _finddata64_t * ft) { - WIN32_FIND_DATAW find_data; - - if (!FindNextFileW((HANDLE)hand, &find_data)) - { - *_errno() = ENOENT; - return -1; - } + struct _wfinddata64_t wft; + int ret;
- msvcrt_wfttofd64(&find_data,ft); - return 0; + ret = _wfindnext64(hand, &wft); + if (!ret && !finddata64_wtoa(&wft, ft)) ret = -1; + return ret; }
/********************************************************************* diff --git a/dlls/ucrtbase/tests/file.c b/dlls/ucrtbase/tests/file.c index a8934338a4b..3663575ca74 100644 --- a/dlls/ucrtbase/tests/file.c +++ b/dlls/ucrtbase/tests/file.c @@ -342,6 +342,12 @@ static void test_utf8(void) fdata64.name[0] = 'x'; hfind = _findfirst64(buf, &fdata64); ok(hfind != -1, "_findfirst64 returned %Id, errno %d\n", hfind, errno); + todo_wine_if(!is_lossless_convertion(dir)) + ok(!memcmp(file, fdata64.name, sizeof(file) - 1), "fdata64.name = %s\n", debugstr_a(fdata64.name)); + + fdata64.name[0] = 'x'; + ret = _findnext64(hfind, &fdata64); + ok(!ret, "_findnext64 returned %d, errno %d\n", ret, errno); todo_wine_if(!is_lossless_convertion(dir)) ok(!memcmp(file, fdata64.name, sizeof(file) - 1), "fdata64.name = %s\n", debugstr_a(fdata64.name)); ret = _findclose(hfind);