merge ROS Shell without integrated explorer part into trunk
[reactos.git] / reactos / subsys / system / explorer / shell / entries.cpp
index e849688..ab75f9d 100644 (file)
@@ -141,6 +141,7 @@ void Entry::read_directory_base(SORT_ORDER sortOrder, int scan_flags)
         // call into subclass
        read_directory(scan_flags);
 
+#ifndef ROSSHELL
        if (g_Globals._prescan_nodes) { //@todo _prescan_nodes should not be used for reading the start menu.
                for(Entry*entry=_down; entry; entry=entry->_next)
                        if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
@@ -148,6 +149,7 @@ void Entry::read_directory_base(SORT_ORDER sortOrder, int scan_flags)
                                entry->sort_directory(sortOrder);
                        }
        }
+#endif
 
        sort_directory(sortOrder);
 }
@@ -168,10 +170,16 @@ Root::~Root()
  // 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;
+       int order2 = fd2->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+
+       /* Handle "." and ".." as special case and move them at the very first beginning. */
+       if (order1 && order2) {
+               order1 = fd1->cFileName[0]!='.'? 1: fd1->cFileName[1]=='.'? 2: fd1->cFileName[1]=='\0'? 3: 1;
+               order2 = fd2->cFileName[0]!='.'? 1: fd2->cFileName[1]=='.'? 2: fd2->cFileName[1]=='\0'? 3: 1;
+       }
 
-       return dir2==dir1? 0: dir2<dir1? -1: 1;
+       return order2==order1? 0: order2<order1? -1: 1;
 }
 
 
@@ -317,7 +325,7 @@ void Entry::extract_icon()
 
        ICON_ID icon_id = ICID_NONE;
 
-       if (get_path(path))
+       if (get_path(path) && _tcsncmp(path,TEXT("::{"),3))
                icon_id = g_Globals._icon_cache.extract(path);
 
        if (icon_id == ICID_NONE) {
@@ -395,7 +403,7 @@ BOOL Entry::launch_entry(HWND hwnd, UINT nCmdShow)
 }
 
 
-HRESULT Entry::do_context_menu(HWND hwnd, const POINT& pos)
+HRESULT Entry::do_context_menu(HWND hwnd, const POINT& pos, CtxMenuInterfaces& cm_ifs)
 {
        ShellPath shell_path = create_absolute_pidl();
        LPCITEMIDLIST pidl_abs = shell_path;
@@ -413,7 +421,7 @@ HRESULT Entry::do_context_menu(HWND hwnd, const POINT& pos)
                HRESULT hr = (*SHBindToParent)(pidl_abs, IID_IShellFolder, (LPVOID*)&parentFolder, &pidlLast);
 
                if (SUCCEEDED(hr)) {
-                       hr = ShellFolderContextMenu(parentFolder, hwnd, 1, &pidlLast, pos.x, pos.y);
+                       hr = ShellFolderContextMenu(parentFolder, hwnd, 1, &pidlLast, pos.x, pos.y, cm_ifs);
 
                        parentFolder->Release();
                }
@@ -436,7 +444,7 @@ HRESULT Entry::do_context_menu(HWND hwnd, const POINT& pos)
                ShellFolder parent_folder = parent_path;
                return ShellFolderContextMenu(parent_folder, hwnd, 1, &pidl, pos.x, pos.y);
                */
-               return ShellFolderContextMenu(GetDesktopFolder(), hwnd, 1, &pidl_abs, pos.x, pos.y);
+               return ShellFolderContextMenu(GetDesktopFolder(), hwnd, 1, &pidl_abs, pos.x, pos.y, cm_ifs);
        }
 }