From: Piotr Caban piotr@codeweavers.com
--- dlls/msvcrt/dir.c | 48 ++++++++++---------------------------- dlls/ucrtbase/tests/file.c | 6 +++++ 2 files changed, 18 insertions(+), 36 deletions(-)
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c index 257f49d5351..0448a2a8523 100644 --- a/dlls/msvcrt/dir.c +++ b/dlls/msvcrt/dir.c @@ -77,26 +77,6 @@ static void msvcrt_fttofd( const WIN32_FIND_DATAA *fd, struct _finddata_t* ft) strcpy(ft->name, fd->cFileName); }
-/* INTERNAL: Translate WIN32_FIND_DATAA to finddata32_t */ -static void msvcrt_fttofd32( const WIN32_FIND_DATAA *fd, struct _finddata32_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 = fd->nFileSizeLow; - strcpy(ft->name, fd->cFileName); -} - /* INTERNAL: Translate WIN32_FIND_DATAW to wfinddata_t */ static void msvcrt_wfttofd( const WIN32_FIND_DATAW *fd, struct _wfinddata_t* ft) { @@ -612,37 +592,33 @@ int CDECL _findnext(intptr_t hand, struct _finddata_t * ft) }
/********************************************************************* - * _findnext32 (MSVCRT.@) + * _wfindnext32 (MSVCRT.@) */ -int CDECL _findnext32(intptr_t hand, struct _finddata32_t * ft) +int CDECL _wfindnext32(intptr_t hand, struct _wfinddata32_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_fttofd32(&find_data, ft); + msvcrt_wfttofd32(&find_data, ft); return 0; }
/********************************************************************* - * _wfindnext32 (MSVCRT.@) + * _findnext32 (MSVCRT.@) */ -int CDECL _wfindnext32(intptr_t hand, struct _wfinddata32_t * ft) +int CDECL _findnext32(intptr_t hand, struct _finddata32_t *ft) { - WIN32_FIND_DATAW find_data; - - if (!FindNextFileW((HANDLE)hand, &find_data)) - { - *_errno() = ENOENT; - return -1; - } + struct _wfinddata32_t wft; + int ret;
- msvcrt_wfttofd32(&find_data, ft); - return 0; + ret = _wfindnext32(hand, &wft); + if (!ret && !finddata32_wtoa(&wft, ft)) ret = -1; + return ret; }
/********************************************************************* diff --git a/dlls/ucrtbase/tests/file.c b/dlls/ucrtbase/tests/file.c index 73aa5da0659..1379759199d 100644 --- a/dlls/ucrtbase/tests/file.c +++ b/dlls/ucrtbase/tests/file.c @@ -327,9 +327,15 @@ static void test_utf8(void) todo_wine_if(!is_lossless_convertion(dir)) ok(!memcmp(file, fdata32.name, sizeof(file) - 1), "fdata32.name = %s\n", debugstr_a(fdata32.name));
+ fdata32.name[0] = 'x'; + ret = _findnext32(hfind, &fdata32); + ok(!ret, "_findnext32 returned %d, errno %d\n", ret, errno); + todo_wine_if(!is_lossless_convertion(dir)) + ok(!memcmp(file, fdata32.name, sizeof(file) - 1), "fdata32.name = %s\n", debugstr_a(fdata32.name)); ret = _findclose(hfind); ok(!ret, "_findclose returned %d, errno %d\n", ret, errno);
+ ret = remove(file2); ok(!ret, "remove returned %d, errno %d\n", ret, errno);