FindFirstFile can return an empty short name if the long name is a

valid DOS name, fixed callers to handle that properly.
This commit is contained in:
Alexandre Julliard 2004-03-17 01:50:27 +00:00
parent ffbb75fe25
commit 22508e576f
3 changed files with 25 additions and 29 deletions

View File

@ -1766,10 +1766,12 @@ static LRESULT LISTBOX_Directory( HWND hwnd, LB_DESCR *descr, UINT attrib,
static const WCHAR bracketW[] = { ']',0 };
static const WCHAR dotW[] = { '.',0 };
if (!(attrib & DDL_DIRECTORY) ||
!strcmpW( entry.cAlternateFileName, dotW )) continue;
!strcmpW( entry.cFileName, dotW )) continue;
buffer[0] = '[';
if (long_names) strcpyW( buffer + 1, entry.cFileName );
else strcpyW( buffer + 1, entry.cAlternateFileName );
if (!long_names && entry.cAlternateFileName[0])
strcpyW( buffer + 1, entry.cAlternateFileName );
else
strcpyW( buffer + 1, entry.cFileName );
strcatW(buffer, bracketW);
}
else /* not a directory */
@ -1781,8 +1783,10 @@ static LRESULT LISTBOX_Directory( HWND hwnd, LB_DESCR *descr, UINT attrib,
((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
continue;
#undef ATTRIBS
if (long_names) strcpyW( buffer, entry.cFileName );
else strcpyW( buffer, entry.cAlternateFileName );
if (!long_names && entry.cAlternateFileName[0])
strcpyW( buffer + 1, entry.cAlternateFileName );
else
strcpyW( buffer + 1, entry.cFileName );
}
if (!long_names) CharLowerW( buffer );
pos = LISTBOX_FindFileStrPos( hwnd, descr, buffer );

View File

@ -1578,16 +1578,8 @@ LPITEMIDLIST _ILCreateFolder( WIN32_FIND_DATAA * stffile )
memcpy (pbuff, stffile->cFileName, len);
pbuff += len;
if (stffile->cAlternateFileName)
{
len1 = strlen (stffile->cAlternateFileName)+1;
memcpy (pbuff, stffile->cAlternateFileName, len1);
}
else
{
len1 = 1;
*pbuff = 0x00;
}
len1 = strlen (stffile->cAlternateFileName)+1;
memcpy (pbuff, stffile->cAlternateFileName, len1);
pidl = _ILCreate(PT_FOLDER, (LPVOID)buff, len + len1);
@ -1618,16 +1610,8 @@ LPITEMIDLIST _ILCreateValue(WIN32_FIND_DATAA * stffile)
memcpy (pbuff, stffile->cFileName, len);
pbuff += len;
if (stffile->cAlternateFileName)
{
len1 = strlen (stffile->cAlternateFileName)+1;
memcpy (pbuff, stffile->cAlternateFileName, len1);
}
else
{
len1 = 1;
*pbuff = 0x00;
}
len1 = strlen (stffile->cAlternateFileName)+1;
memcpy (pbuff, stffile->cAlternateFileName, len1);
pidl = _ILCreate(PT_VALUE, (LPVOID)buff, len + len1);

View File

@ -3754,7 +3754,8 @@ static unsigned INT21_FindHelper(LPCWSTR fullPath, unsigned drive, unsigned coun
count++;
/* Check the file attributes, and path */
if (!(entry->dwFileAttributes & ~search_attr) &&
match_short(entry->cAlternateFileName, mask))
match_short(entry->cAlternateFileName[0] ? entry->cAlternateFileName : entry->cFileName,
mask))
{
return count;
}
@ -3787,8 +3788,12 @@ static int INT21_FindNext( CONTEXT86 *context )
dta->fileattr = entry.dwFileAttributes;
dta->filesize = entry.nFileSizeLow;
FileTimeToDosDateTime( &entry.ftLastWriteTime, &dta->filedate, &dta->filetime );
WideCharToMultiByte(CP_OEMCP, 0, entry.cAlternateFileName, -1,
dta->filename, 13, NULL, NULL);
if (entry.cAlternateFileName[0])
WideCharToMultiByte(CP_OEMCP, 0, entry.cAlternateFileName, -1,
dta->filename, 13, NULL, NULL);
else
WideCharToMultiByte(CP_OEMCP, 0, entry.cFileName, -1, dta->filename, 13, NULL, NULL);
if (!memchr(dta->mask,'?',11))
{
/* wildcardless search, release resources in case no findnext will
@ -3887,7 +3892,10 @@ static int INT21_FindNextFCB( CONTEXT86 *context )
&pResult->filedate, &pResult->filetime );
/* Convert file name to FCB format */
INT21_ToDosFCBFormat( entry.cAlternateFileName, nameW );
if (entry.cAlternateFileName[0])
INT21_ToDosFCBFormat( entry.cAlternateFileName, nameW );
else
INT21_ToDosFCBFormat( entry.cFileName, nameW );
WideCharToMultiByte(CP_OEMCP, 0, nameW, 11, pResult->filename, 11, NULL, NULL);
return 1;
}