Skip to content

Commit

Permalink
feat: opens sole folder instead of upper folder after extraction; can…
Browse files Browse the repository at this point in the history
…cel folder priority over file in comparison; other minor ui fix
  • Loading branch information
shunf4 committed May 11, 2024
1 parent 7c6d4e7 commit 6b5da20
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 25 deletions.
4 changes: 2 additions & 2 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

#define MY_EASY7ZIP_7ZIP "Easy 7-Zip"

#define MY_EASY7ZIP_VERSION "0.1.6-shunf4"
#define MY_EASY7ZIP_VERSION "0.1.6-shunf4-2"

#define MY_EASY7ZIP_7ZIP_VERSION "Easy 7-Zip v0.1.6-shunf4"
#define MY_EASY7ZIP_7ZIP_VERSION "Easy 7-Zip v0.1.6-shunf4-2"

#define MY_EASY7ZIP_COPYRIGHT "Portions Copyright (C) 2013-2016 James Hoo"

Expand Down
2 changes: 1 addition & 1 deletion CPP/7zip/UI/Agent/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ Z7_COM7F_IMF(CAgentFolder::Extract(const UInt32 *indices,
// do we need another base folder for subfolders ?
extractCallbackSpec->DirPathPrefix_for_HashFiles = _agentSpec->_hashBaseFolderPrefix;

extractCallbackSpec->SoleFolderIndex = soleFolderIndex;
extractCallbackSpec->SoleFolderIndex = soleFolderIndex == -1LL ? -1LL : GetRealIndex((int)soleFolderIndex);

CUIntVector realIndices;
GetRealIndices(indices, numItems, IntToBool(includeAltStreams),
Expand Down
53 changes: 51 additions & 2 deletions CPP/7zip/UI/FileManager/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma

SetFocusedPanel(LastFocusedPanel);
Panels[LastFocusedPanel].SetFocusToList();

if (pDelayedOpenFolderAfterExtractPathCriticalSection == NULL) {
pDelayedOpenFolderAfterExtractPathCriticalSection = new NWindows::NSynchronization::CCriticalSection();
}

return S_OK;
}

Expand Down Expand Up @@ -409,6 +414,10 @@ void CApp::Save()

void CApp::Release()
{
if (pDelayedOpenFolderAfterExtractPathCriticalSection != NULL) {
delete pDelayedOpenFolderAfterExtractPathCriticalSection;
pDelayedOpenFolderAfterExtractPathCriticalSection = NULL;
}
// It's for unloading COM dll's: don't change it.
for (unsigned i = 0; i < kNumPanelsMax; i++)
Panels[i].Release();
Expand Down Expand Up @@ -885,9 +894,49 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex)

if (!g_bProcessError && result == S_OK)
{
if (openOutputFolder && IsDirectory(destPath))
if (openOutputFolder)
{
StartApplicationDontWait(destPath, destPath, (HWND)_window);
bool done = false;
if (!done && soleFolderIndex != -1LL) {
UString soleFolderName = srcPanel.GetItemRelPath((UInt32)soleFolderIndex);
if (soleFolderName.Len() > 0 && (soleFolderName[0] == L'\\' || soleFolderName[0] == L'/' || soleFolderName[0] == '\\' || soleFolderName[0] == '/')) {
soleFolderName = soleFolderName.Mid(1, soleFolderName.Len() - 1);
}
if (soleFolderName.Len() > 0 && (soleFolderName.Back() == L'\\' || soleFolderName.Back() == L'/' || soleFolderName.Back() == '\\' || soleFolderName.Back() == '/')) {
soleFolderName.DeleteBack();
}
UString destPathWithSoleFolder = destPath;
destPathWithSoleFolder += L'\\';
destPathWithSoleFolder += soleFolderName;
if (IsDirectory(destPathWithSoleFolder)) {
done = true;
if (close7Zip)
{
StartApplicationDontWait(destPathWithSoleFolder, destPathWithSoleFolder, (HWND)_window);
} else {
{
NWindows::NSynchronization::CCriticalSectionLock lock(*pDelayedOpenFolderAfterExtractPathCriticalSection);
DelayedOpenFolderAfterExtractPath = destPathWithSoleFolder;
}
_window.SetTimer(1678, 800);
}
}
}

if (!done) {
if (IsDirectory(destPath)) {
if (close7Zip)
{
StartApplicationDontWait(destPath, destPath, (HWND)_window);
} else {
{
NWindows::NSynchronization::CCriticalSectionLock lock(*pDelayedOpenFolderAfterExtractPathCriticalSection);
DelayedOpenFolderAfterExtractPath = destPath;
}
_window.SetTimer(1678, 800);
}
}
}
}
if (deleteSourceFile)
{
Expand Down
7 changes: 6 additions & 1 deletion CPP/7zip/UI/FileManager/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class CApp
bool ShowButtonsLables;
bool LargeButtons;

UString DelayedOpenFolderAfterExtractPath;
NWindows::NSynchronization::CCriticalSection *pDelayedOpenFolderAfterExtractPathCriticalSection;

CAppState AppState;
CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
CPanel Panels[kNumPanelsMax];
Expand All @@ -91,7 +94,9 @@ class CApp
_window(NULL),
AutoRefresh_Mode(true),
NumPanels(2),
LastFocusedPanel(0)
LastFocusedPanel(0),
DelayedOpenFolderAfterExtractPath(L""),
pDelayedOpenFolderAfterExtractPathCriticalSection(NULL)
{
SetPanels_AutoRefresh_Mode();
}
Expand Down
18 changes: 18 additions & 0 deletions CPP/7zip/UI/FileManager/FM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,24 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
break;
}

case WM_TIMER:
{
if (wParam == 1678) {
KillTimer(hWnd, 1678);
UString p;
{
NWindows::NSynchronization::CCriticalSectionLock lock(*g_App.pDelayedOpenFolderAfterExtractPathCriticalSection);
p = g_App.DelayedOpenFolderAfterExtractPath;
g_App.DelayedOpenFolderAfterExtractPath.Wipe_and_Empty();
}

if (!p.IsEmpty()) {
StartApplicationDontWait(p, p, hWnd);
}
}
break;
}

/*
case WM_DROPFILES:
Expand Down
14 changes: 11 additions & 3 deletions CPP/7zip/UI/FileManager/PanelDrag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,10 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */, bool isRightButton)
}
}

if (dataObjectSpec->m_Transfer.Target.Cmd_Type == NDragMenu::k_OpenArc) {
need_Process = false;
}

if (need_Process)
if (!dataObjectSpec->DestDirPrefix_FromTarget.IsEmpty())
{
Expand Down Expand Up @@ -1972,8 +1976,6 @@ void CDropTarget::PositionCursor(const POINTL &ptl)
{
m_Panel = panel;
m_IsAppTarget = false;
if ((int)i == SrcPanelIndex)
return; // we don't allow to drop to source panel

POINT pt3 = pt;
if (panel->ScreenToClient(&pt3)) {
Expand All @@ -1986,6 +1988,9 @@ void CDropTarget::PositionCursor(const POINTL &ptl)
m_IsPanelAddressComboBoxOrBar = true;
}
}

if ((int)i == SrcPanelIndex && !m_IsPanelAddressComboBoxOrBar)
return; // we don't allow to drop to source panel

break;
}
Expand Down Expand Up @@ -2770,13 +2775,16 @@ Z7_COMWF_B CDropTarget::Drop(IDataObject *dataObject, DWORD keyState,
// res = SendToSource_UInt32(dataObject, RegisterClipboardFormat(CFSTR_LOGICALPERFORMEDDROPEFFECT), DROPEFFECT_MOVE); // for debug
/* res = */ SendToSource_UInt32(dataObject,
RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT),
cmd == NDragMenu::k_Cancel ? DROPEFFECT_NONE : DROPEFFECT_COPY);
((cmd == NDragMenu::k_Cancel) || (cmd == NDragMenu::k_OpenArc)) ? DROPEFFECT_NONE : DROPEFFECT_COPY);
// res = res;
}
RemoveSelection();

target.FuncType = k_DragTargetMode_Drop_End;
target.Cmd_Type = cmd;
if (cmd == NDragMenu::k_OpenArc) {
needDrop_by_Source = false;
}
if (needDrop_by_Source)
target.Flags |= k_TargetFlags_MustBeProcessedBySource;

Expand Down
4 changes: 2 additions & 2 deletions CPP/7zip/UI/FileManager/PanelSort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
const bool isDir1 = panel->IsItem_Folder((unsigned)lParam1);
const bool isDir2 = panel->IsItem_Folder((unsigned)lParam2);

if (isDir1 && !isDir2) return -1;
if (isDir2 && !isDir1) return 1;
// if (isDir1 && !isDir2) return -1;
// if (isDir2 && !isDir1) return 1;

const int result = CompareItems2(lParam1, lParam2, lpData);
return panel->_ascending ? result: (-result);
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ print message in a dialog
#include <winuser.h>
#include <strsafe.h>
char a[100] {};
StringCbPrintfA(a, 100, "index=%u SoleFolderIndex=%ull", _index, SoleFolderIndex);
MessageBoxA(0, a, "AAA", MB_ICONERROR);
{
char a[100] {};
StringCbPrintfA(a, 100, "index=%u SoleFolderIndex=%lld", _index, SoleFolderIndex);
MessageBoxA(0, a, "AAA", MB_ICONERROR);
}
```
61 changes: 50 additions & 11 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
set OPTS=Z7_SFX=1 PLATFORM=x64
set LFLAGS=/DEBUG /SUBSYSTEM:WINDOWS,"5.02"

taskkill /f /im 7zFM.exe
taskkill /f /im 7zG.exe

set HAS_ERROR=FALSE

@echo ^_^_^_^_^_ ^_ ^_ ^_^_ ^_^_
@echo ^| ^_^_^_(^_) ^| ^_^_^_^| \^/ ^| ^_^_ ^_ ^_ ^_^_ ^_^_ ^_ ^_^_ ^_ ^_^_^_ ^_ ^_^_
@echo ^| ^|^_ ^| ^| ^|^/ ^_ \ ^|\^/^| ^|^/ ^_^` ^| '^_ \ ^/ ^_^` ^|^/ ^_^` ^|^/ ^_ \ '^_^_^|
Expand All @@ -14,7 +19,10 @@ set O=%~dp0out\FileManager
mkdir %O%
pushd %~dp0CPP\7zip\UI\FileManager
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7zFM.exe" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7zFM.exe" >> errorfile.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_^_^_^_ ^_^_^_^_ ^_ ^_ ^_^_^_
Expand All @@ -27,7 +35,10 @@ set O=%~dp0out\GUI
mkdir %O%
pushd %~dp0CPP\7zip\UI\GUI
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7zG.exe" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7zG.exe" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_^_^_^_ ^_^_^_^_^_ ^_
Expand All @@ -41,7 +52,10 @@ set O=%~dp0out\Explorer
mkdir %O%
pushd %~dp0CPP\7zip\UI\Explorer
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7-zip.dll" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7-zip.dll" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_^_^_ ^_^_ ^_^_ ^_^_^_
Expand All @@ -55,7 +69,10 @@ set O=%~dp0out\SFXWin
mkdir %O%
pushd %~dp0CPP\7zip\Bundles\SFXWin
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7z.sfx" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7z.sfx" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_^_^_^_ ^_ ^_^_^_ ^_ ^_ ^_
Expand All @@ -69,7 +86,10 @@ set O=%~dp0out\7zipInstall
mkdir %O%
pushd %~dp0C\Util\7zipInstall
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ Install-x64.exe" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ Install-x64.exe" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_^_^_^_ ^_ ^_ ^_ ^_^_^_ ^_ ^_ ^_
Expand All @@ -83,7 +103,10 @@ set O=%~dp0out\7zipUninstall
mkdir %O%
pushd %~dp0C\Util\7zipUninstall
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ Uninstall.exe" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ Uninstall.exe" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

set LFLAGS=/SUBSYSTEM:CONSOLE,"5.02"
Expand All @@ -98,7 +121,10 @@ set O=%~dp0out\Console
mkdir %O%
pushd %~dp0CPP\7zip\UI\Console
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7z.exe" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7z.exe" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_ ^_
Expand All @@ -111,7 +137,10 @@ set O=%~dp0out\SFXCon
mkdir %O%
pushd %~dp0CPP\7zip\Bundles\SFXCon
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7zCon.sfx" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7zCon.sfx" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

@echo ^_^_ ^_ ^_^_^_^_^_
Expand All @@ -124,11 +153,21 @@ set O=%~dp0out\Format7zF
mkdir %O%
pushd %~dp0CPP\7zip\Bundles\Format7zF
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error x64 @ 7z.dll" >> errorfile.txt
IF %errorlevel% NEQ 0 (
echo "Error x64 @ 7z.dll" >> errorfile\.txt
set HAS_ERROR=TRUE
)
popd

powershell -Command Copy-Item .\out\*\*.exe,.\out\*\*.dll,.\out\*\*.pdb,.\out\*\*.sfx -Destination .\out\ -Verbose -Force
rem explorer.exe %~dp0out

rem clear errorlevel
type nul
if %HAS_ERROR% == TRUE (
echo HAS ERROR
echo HAS ERROR
echo HAS ERROR
echo HAS ERROR
exit /b 1
)

exit /b 0
5 changes: 5 additions & 0 deletions rungui.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
taskkill /f /im 7zFM.exe
taskkill /f /im 7zG.exe

start "" .\out\7zFM.exe

0 comments on commit 6b5da20

Please sign in to comment.