- 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:
parent
1c8d9b66c3
commit
634c7a49c4
@ -987,13 +987,42 @@ static void read_directory_shell(Entry* dir, HWND hwnd)
|
|||||||
#endif /* _SHELL_FOLDERS */
|
#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... */
|
/* directories first... */
|
||||||
static int compareType(const WIN32_FIND_DATA* fd1, const WIN32_FIND_DATA* fd2)
|
static int compareType(const WIN32_FIND_DATA* fd1, const WIN32_FIND_DATA* fd2)
|
||||||
{
|
{
|
||||||
int dir1 = fd1->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
int order1 = fd1->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY? TO_DIR: TO_FILE;
|
||||||
int dir2 = fd2->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,8 +143,6 @@ typedef struct
|
|||||||
TCHAR drives[BUFFER_LEN];
|
TCHAR drives[BUFFER_LEN];
|
||||||
BOOL prescan_node; /*TODO*/
|
BOOL prescan_node; /*TODO*/
|
||||||
|
|
||||||
UINT wStringTableOffset;
|
|
||||||
|
|
||||||
#ifdef _SHELL_FOLDERS
|
#ifdef _SHELL_FOLDERS
|
||||||
IShellFolder* iDesktop;
|
IShellFolder* iDesktop;
|
||||||
IMalloc* iMalloc;
|
IMalloc* iMalloc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user