- Handle "." and ".." as special case and move them at the very first

beginning of directory listings.
- Remove unused variable wStringTableOffset.
This commit is contained in:
Martin Fuchs 2004-09-22 19:11:49 +00:00 committed by Alexandre Julliard
parent 1c8d9b66c3
commit 634c7a49c4
2 changed files with 32 additions and 5 deletions

View File

@ -987,13 +987,42 @@ static void read_directory_shell(Entry* dir, HWND hwnd)
#endif /* _SHELL_FOLDERS */
/* sort order for different directory/file types */
enum TYPE_ORDER {
TO_DIR = 0,
TO_DOT = 1,
TO_DOTDOT = 2,
TO_OTHER_DIR = 3,
TO_FILE = 4
};
/* distinguish between ".", ".." and any other directory names */
static int TypeOrderFromDirname(LPCTSTR name)
{
if (name[0] == '.') {
if (name[1] == '\0')
return TO_DOT; /* "." */
if (name[1]=='.' && name[2]=='\0')
return TO_DOTDOT; /* ".." */
}
return TO_OTHER_DIR; /* anything else */
}
/* directories first... */
static int compareType(const WIN32_FIND_DATA* fd1, const WIN32_FIND_DATA* fd2)
{
int dir1 = fd1->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
int dir2 = fd2->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
int order1 = fd1->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY? TO_DIR: TO_FILE;
int order2 = fd2->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY? TO_DIR: TO_FILE;
return dir2==dir1? 0: dir2<dir1? -1: 1;
/* Handle "." and ".." as special case and move them at the very first beginning. */
if (order1==TO_DIR && order2==TO_DIR) {
order1 = TypeOrderFromDirname(fd1->cFileName);
order2 = TypeOrderFromDirname(fd2->cFileName);
}
return order2==order1? 0: order1<order2? -1: 1;
}

View File

@ -143,8 +143,6 @@ typedef struct
TCHAR drives[BUFFER_LEN];
BOOL prescan_node; /*TODO*/
UINT wStringTableOffset;
#ifdef _SHELL_FOLDERS
IShellFolder* iDesktop;
IMalloc* iMalloc;