Skip to content

Commit

Permalink
When junctions are hidden, also hide from left pane
Browse files Browse the repository at this point in the history
  • Loading branch information
malxau committed Feb 1, 2022
1 parent b56f8e5 commit 3f48ecf
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 11 deletions.
18 changes: 17 additions & 1 deletion src/lfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

BOOL IsFATName(LPTSTR pName);


/* WFFindFirst -
*
* returns:
Expand Down Expand Up @@ -69,6 +68,14 @@ WFFindFirst(

lpFind->fd.dwFileAttributes &= ATTR_USED;

if (lpFind->fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
if (lpFind->fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT) {
lpFind->fd.dwFileAttributes |= ATTR_JUNCTION;
} else if (lpFind->fd.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
lpFind->fd.dwFileAttributes |= ATTR_SYMBOLIC;
}
}

Wow64RevertWow64FsRedirection(oldValue);

//
Expand Down Expand Up @@ -139,7 +146,16 @@ WFFindNext(LPLFNDTA lpFind)
lstrcpy(lpFind->fd.cFileName, lpFind->fd.cAlternateFileName);
}

if (lpFind->fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
if (lpFind->fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT) {
lpFind->fd.dwFileAttributes |= ATTR_JUNCTION;
} else if (lpFind->fd.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
lpFind->fd.dwFileAttributes |= ATTR_SYMBOLIC;
}
}

Wow64RevertWow64FsRedirection(oldValue);

lpFind->err = 0;
return TRUE;
}
Expand Down
65 changes: 55 additions & 10 deletions src/treectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ ScanDirLevel(PDNODE pParentNode, LPTSTR szPath, DWORD view)
{
BOOL bFound;
LFNDTA lfndta;
BOOL bExclude;

/* Add '*.*' to the current path. */
lstrcpy(szMessage, szPath);
Expand All @@ -178,9 +179,18 @@ ScanDirLevel(PDNODE pParentNode, LPTSTR szPath, DWORD view)

while (bFound)
{
/* Is this a junction and are those displayed? */
bExclude = FALSE;
if ((view & ATTR_JUNCTION) == 0 &&
(lfndta.fd.dwFileAttributes & ATTR_JUNCTION)) {

bExclude = TRUE;
}

/* Is this not a '.' or '..' directory? */
if (!ISDOTDIR(lfndta.fd.cFileName) &&
(lfndta.fd.dwFileAttributes & ATTR_DIR)) {
(lfndta.fd.dwFileAttributes & ATTR_DIR) &&
!bExclude) {

pParentNode->wFlags |= TF_HASCHILDREN;
bFound = FALSE;
Expand Down Expand Up @@ -663,6 +673,22 @@ ReadDirLevel(
lstrcpy(szMessage, szPath);

bFound = WFFindFirst(&lfndta, szMessage, dwAttribs);
if (bFound)
{
while (TRUE)
{
// If it's a junction and we're not displaying those,
// loop again for the next entry
if (lfndta.fd.dwFileAttributes & ATTR_JUNCTION &&
(!(dwAttribs & ATTR_JUNCTION)))
{

bFound = WFFindNext(&lfndta); // get it from dos
continue;
}
break;
}
}
}

// for net drive case where we can't actually see what is in these
Expand Down Expand Up @@ -787,7 +813,7 @@ ReadDirLevel(
goto DONE;
}
} else if (dwView & VIEW_PLUSES) {
ScanDirLevel(pNode, szPath, dwAttribs & ATTR_HS);
ScanDirLevel(pNode, szPath, dwAttribs & (ATTR_HS | ATTR_JUNCTION));
}
}

Expand Down Expand Up @@ -836,7 +862,22 @@ ReadDirLevel(
}
else
{
bFound = WFFindNext(&lfndta); // get it from dos
while (TRUE)
{
bFound = WFFindNext(&lfndta); // get it from dos
if (bFound)
{
// If it's a junction and we're not displaying those,
// loop again for the next entry
if (lfndta.fd.dwFileAttributes & ATTR_JUNCTION &&
(!(dwAttribs & ATTR_JUNCTION)))
{

continue;
}
}
break;
}
}
}

Expand Down Expand Up @@ -932,7 +973,7 @@ StealTreeData(
// we need to match on these attributes as well as the name
//
dwView = GetWindowLongPtr(GetParent(hwndTC), GWL_VIEW) & VIEW_PLUSES;
dwAttribs = GetWindowLongPtr(GetParent(hwndTC), GWL_ATTRIBS) & ATTR_HS;
dwAttribs = GetWindowLongPtr(GetParent(hwndTC), GWL_ATTRIBS) & (ATTR_HS | ATTR_JUNCTION);

//
// get the dir of this new window for compare below
Expand All @@ -948,7 +989,7 @@ StealTreeData(
(hwndT != hwndTC) &&
!GetWindowLongPtr(hwndT, GWL_READLEVEL) &&
(dwView == (DWORD)(GetWindowLongPtr(hwndSrc, GWL_VIEW) & VIEW_PLUSES)) &&
(dwAttribs == (DWORD)(GetWindowLongPtr(hwndSrc, GWL_ATTRIBS) & ATTR_HS))) {
(dwAttribs == (DWORD)(GetWindowLongPtr(hwndSrc, GWL_ATTRIBS) & (ATTR_HS | ATTR_JUNCTION)))) {

SendMessage(hwndSrc, FS_GETDIRECTORY, COUNTOF(szSrc), (LPARAM)szSrc);
StripBackslash(szSrc);
Expand Down Expand Up @@ -1084,7 +1125,8 @@ FillTreeListbox(HWND hwndTC,

if (pNode) {

dwAttribs = ATTR_DIR | (GetWindowLongPtr(GetParent(hwndTC), GWL_ATTRIBS) & ATTR_HS);
dwAttribs = GetWindowLongPtr(GetParent(hwndTC), GWL_ATTRIBS);
dwAttribs = ATTR_DIR | (dwAttribs & (ATTR_HS | ATTR_JUNCTION));
cNodes = 0;
bCancelTree = FALSE;

Expand Down Expand Up @@ -1155,7 +1197,8 @@ FillOutTreeList(HWND hwndTC,

SendMessage(hwndLB, WM_SETREDRAW, FALSE, 0L);

dwAttribs = ATTR_DIR | (GetWindowLongPtr(GetParent(hwndTC), GWL_ATTRIBS) & ATTR_HS);
dwAttribs = GetWindowLongPtr(GetParent(hwndTC), GWL_ATTRIBS);
dwAttribs = ATTR_DIR | (dwAttribs & (ATTR_HS | ATTR_JUNCTION));

// get path to node that already exists in tree; will start reading from there
GetTreePath(pNode, szExists);
Expand Down Expand Up @@ -1861,6 +1904,7 @@ ExpandLevel(HWND hWnd, WPARAM wParam, INT nIndex, LPTSTR szPath)
INT iExpandInView;
INT iCurrentIndex;
RECT rc;
DWORD dwAttribs;

//
// Don't do anything while the tree is being built.
Expand Down Expand Up @@ -1916,8 +1960,9 @@ ExpandLevel(HWND hWnd, WPARAM wParam, INT nIndex, LPTSTR szPath)

if (IsTheDiskReallyThere(hWnd, szPath, FUNC_EXPAND, FALSE))
{
ReadDirLevel(hWnd, pNode, szPath, pNode->nLevels + 1, nIndex,
(DWORD)(ATTR_DIR | (GetWindowLongPtr(GetParent(hWnd), GWL_ATTRIBS) & ATTR_HS)),
dwAttribs = GetWindowLongPtr(GetParent(hWnd), GWL_ATTRIBS);
dwAttribs = ATTR_DIR | (dwAttribs & (ATTR_HS | ATTR_JUNCTION));
ReadDirLevel(hWnd, pNode, szPath, pNode->nLevels + 1, nIndex, dwAttribs,
(BOOL)wParam, NULL, IS_PARTIALSORT(DRIVEID(szPath)));
}

Expand Down Expand Up @@ -2355,7 +2400,7 @@ TreeControlWndProc(
lstrcpy(szPath, (LPTSTR)lParam);
ScanDirLevel( (PDNODE)pNodeT,
szPath,
(GetWindowLongPtr(hwndParent, GWL_ATTRIBS) & ATTR_HS));
(GetWindowLongPtr(hwndParent, GWL_ATTRIBS) & (ATTR_HS | ATTR_JUNCTION)));

//
// Invalidate the window so the plus gets drawn if needed
Expand Down

0 comments on commit 3f48ecf

Please sign in to comment.