Skip to content

Commit

Permalink
Fix code that checks whether hard links can be pasted
Browse files Browse the repository at this point in the history
In 79e5e09, the code that checks to see
whether a hard link can be pasted was updated to simply check whether
the current folder is a filesystem folder. That's not correct, though,
as there needs to be data in the appropriate format on the clipboard.

Prior to that change, there was a check to see whether data could be
pasted. That isn't correct either, though. It's not enough to know that
data can be pasted, since:

- The data needs to be in a specific format (CF_HDROP).
- The paste needs to occur in a filesystem folder.

Therefore, the code that checks to see whether a hard link can be pasted
has been updated to verify the above items.
  • Loading branch information
derceg committed May 1, 2024
1 parent ba94c46 commit 27d2d4e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Explorer++/Explorer++/DirectoryOperationsHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ bool CanPasteInDirectory(PCIDLIST_ABSOLUTE pidl, PasteType pasteType)
|| (pasteType == PasteType::Normal && CanPasteCustomDataInDirectory(pidl));
}

bool CanCreateHardLinkInDirectory(PCIDLIST_ABSOLUTE pidl)
bool CanPasteHardLinkInDirectory(PCIDLIST_ABSOLUTE pidl)
{
return IsFilesystemFolder(pidl);
return IsClipboardFormatAvailable(CF_HDROP) && IsFilesystemFolder(pidl);
}

bool CanCreateInDirectory(PCIDLIST_ABSOLUTE pidl)
Expand Down
2 changes: 1 addition & 1 deletion Explorer++/Explorer++/DirectoryOperationsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include "../Helper/ClipboardHelper.h"

bool CanPasteInDirectory(PCIDLIST_ABSOLUTE pidl, PasteType pasteType);
bool CanCreateHardLinkInDirectory(PCIDLIST_ABSOLUTE pidl);
bool CanPasteHardLinkInDirectory(PCIDLIST_ABSOLUTE pidl);
bool CanCreateInDirectory(PCIDLIST_ABSOLUTE pidl);
bool CanCustomizeDirectory(PCIDLIST_ABSOLUTE pidl);
2 changes: 1 addition & 1 deletion Explorer++/Explorer++/Explorer++.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ class Explorerplusplus :
BOOL CanDelete() const override;
BOOL CanShowFileProperties() const override;
BOOL CanPaste(PasteType pasteType) const override;
bool CanCreateHardLink() const;
bool CanPasteHardLink() const;
BOOL TestItemAttributes(SFGAOF attributes) const;
HRESULT GetSelectionAttributes(SFGAOF *pItemAttributes) const;
PidlAbsolute MaybeGetFocusedDirectory() const;
Expand Down
4 changes: 2 additions & 2 deletions Explorer++/Explorer++/FileSelectionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ BOOL Explorerplusplus::CanPaste(PasteType pasteType) const
return CanPasteInDirectory(directory.Raw(), pasteType);
}

bool Explorerplusplus::CanCreateHardLink() const
bool Explorerplusplus::CanPasteHardLink() const
{
const auto *activeShellBrowser = GetActiveShellBrowserImpl();
return CanCreateHardLinkInDirectory(activeShellBrowser->GetDirectoryIdl().get());
return CanPasteHardLinkInDirectory(activeShellBrowser->GetDirectoryIdl().get());
}

PidlAbsolute Explorerplusplus::MaybeGetFocusedDirectory() const
Expand Down
2 changes: 1 addition & 1 deletion Explorer++/Explorer++/HandleWindowState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Explorerplusplus::SetProgramMenuItemStates(HMENU hProgramMenu)
MenuHelper::EnableItem(hProgramMenu, IDM_EDIT_UNDO, m_FileActionHandler.CanUndo());
MenuHelper::EnableItem(hProgramMenu, IDM_EDIT_PASTE, CanPaste(PasteType::Normal));
MenuHelper::EnableItem(hProgramMenu, IDM_EDIT_PASTESHORTCUT, CanPaste(PasteType::Shortcut));
MenuHelper::EnableItem(hProgramMenu, IDM_EDIT_PASTEHARDLINK, CanCreateHardLink());
MenuHelper::EnableItem(hProgramMenu, IDM_EDIT_PASTEHARDLINK, CanPasteHardLink());

/* The following menu items are only enabled when one
or more files are selected (they represent file
Expand Down

0 comments on commit 27d2d4e

Please sign in to comment.