Skip to content

Commit

Permalink
Duplicate File Detection / Performance Enhancements
Browse files Browse the repository at this point in the history
- Added new tabbed view pane to view duplicate files.
- Modified grid drawing technique to prevent visual artifacts that appears after enabling GDI scaling mode.
- Renamed GraphView to TreeMapView.
- Renamed DirStatView to FileTreeView.
- Renamed TypeView to ExtensionView.
- Separated out control and view source / headers to be consistent.
- Changed Pacman static control (bottom of screen) to use double buffering.
- Sorted and addressed some issues in language files.
- Removed unused language resources.
- Various refactoring.
  • Loading branch information
NoMoreFood committed Apr 16, 2024
1 parent 7841373 commit 9700485
Show file tree
Hide file tree
Showing 97 changed files with 4,026 additions and 3,195 deletions.
39 changes: 14 additions & 25 deletions common/CommonHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,23 @@ CStringW MyStrRetToString(const LPITEMIDLIST pidl, const STRRET* strret)
return s;
}

BOOL ShellExecuteNoThrow(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
{
SHELLEXECUTEINFO sei = {
sizeof(SHELLEXECUTEINFO),
0,
hwnd,
lpVerb,
lpFile,
lpParameters,
lpDirectory,
nShowCmd,
nullptr, // hInstApp
nullptr,
nullptr,
nullptr,
0, // dwHotKey
{},
nullptr
};

return ::ShellExecuteEx(&sei);
}

BOOL ShellExecuteThrow(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
BOOL ShellExecuteThrow(HWND hwnd, const LPCWSTR lpVerb, const LPCWSTR lpFile,
const LPCWSTR lpParameters, const LPCWSTR lpDirectory, const INT nShowCmd)
{
CWaitCursor wc;

const BOOL bResult = ShellExecuteNoThrow(hwnd, lpVerb, lpFile, lpParameters, lpDirectory, nShowCmd);
SHELLEXECUTEINFO sei;
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = 0;
sei.hwnd = hwnd;
sei.lpVerb = lpVerb;
sei.lpFile = lpFile;
sei.lpParameters = lpParameters;
sei.lpDirectory = lpDirectory;
sei.nShow = nShowCmd;

const BOOL bResult = ::ShellExecuteEx(&sei);
if (!bResult)
{
MdThrowStringExceptionF(L"ShellExecute failed: %1!s!", MdGetWinErrorText(::GetLastError()).GetString());
Expand Down
5 changes: 2 additions & 3 deletions common/CommonHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
#include <string>

BOOL ShellExecuteThrow(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
BOOL ShellExecuteNoThrow(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
CStringW MyStrRetToString(const LPITEMIDLIST pidl, const STRRET* strret);
CStringW MyStrRetToString(LPITEMIDLIST pidl, const STRRET* strret);
CStringW GetBaseNameFromPath(LPCWSTR path);
CStringW GetAppFileName(const CStringW& ext = L"");
CStringW GetAppFolder();
std::wstring GetNameFromSid(const PSID sid);
std::wstring GetNameFromSid(PSID sid);
68 changes: 20 additions & 48 deletions common/Tracer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tracer.h - Implementation of tracer class for debugging purposes
// Ttracer.h - Implementation of tracer class for debugging purposes
//
// NOTE: this file is under MIT license as opposed to the project as a whole.
//
Expand Down Expand Up @@ -26,80 +26,51 @@
// Author(s): - Oliver
//

#pragma once

#include "tracer.h"
#include "stdafx.h"
#include "Tracer.h"
#include <cstdarg>
#include <fcntl.h>
#include <io.h>
#include <conio.h>

#ifdef _DEBUG
#if VTRACE_TO_CONSOLE
CWDSTracerConsole::CWDSTracerConsole()
{
int hCrt;
FILE *hf;
::AllocConsole();
::SetConsoleTitle(L"WinDirStat debug trace output");
::SetConsoleTitle(L"WinDirStat Debug Trace Output");
// Standard output
hCrt = _open_osfhandle((intptr_t)::GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
hf = _fdopen(hCrt, "w");
int hCrt = _open_osfhandle(reinterpret_cast<intptr_t>(::GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
FILE * hf = _fdopen(hCrt, "w");
*stdout = *hf;
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdout, nullptr, _IONBF, 0);
// Standard error
hCrt = _open_osfhandle((intptr_t)::GetStdHandle(STD_ERROR_HANDLE), _O_TEXT);
hCrt = _open_osfhandle(reinterpret_cast<intptr_t>(::GetStdHandle(STD_ERROR_HANDLE)), _O_TEXT);
hf = _fdopen(hCrt, "w");
*stderr = *hf;
setvbuf(stderr, NULL, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
}

CWDSTracerConsole::~CWDSTracerConsole()
{
_tprintf(L"Press a key to continue/close.\n");
wprintf(L"Press a key to continue/close.\n");
(void)_getch();
::FreeConsole();
}
#endif // VTRACE_TO_CONSOLE

CWDSTracer::CWDSTracer(LPCSTR srcfile, LPCSTR fctname, unsigned int srcline)
CWDSTracer::CWDSTracer(LPCWSTR srcfile, LPCWSTR fctname, unsigned int srcline)
: m_srcfile(srcfile)
, m_srcline(srcline)
, m_srcfunc(fctname)
// we can rely on the format with back slashes, no need to check forward slashes here
, m_srcbasename((srcfile) ? strrchr(srcfile, '\\') : NULL)
, m_srcbasename((srcfile) ? wcsrchr(srcfile, '\\') : nullptr)
{
// Skip over the backslash
m_srcbasename = (m_srcbasename) ? m_srcbasename + 1 : srcfile;
}

void CWDSTracer::operator()(LPCSTR format, ...) // ANSI
{
CStringA str;
va_list args;
va_start(args, format);
str.FormatV(format, args);
va_end(args);
CStringA strDbg, strPfx;
# if (VTRACE_DETAIL == VTRACE_FILE_LINE_FUNC)
strPfx.Format("%hs:%u|%hs", m_srcbasename, m_srcline, m_srcfunc);
# elif (VTRACE_DETAIL == VTRACE_FILE_LINE)
strPfx.Format("%hs:%u", m_srcbasename, m_srcline);
# elif (VTRACE_DETAIL == VTRACE_FUNC)
strPfx = m_srcfunc;
# endif
if(strPfx.IsEmpty())
strDbg.Format("%hs\n", str.GetBuffer());
else
strDbg.Format("[%hs] %hs\n", strPfx.GetBuffer(), str.GetBuffer());
# if !VTRACE_TO_CONSOLE || (VTRACE_TO_CONSOLE && !VTRACE_NO_OUTPUTDEBUGSTRING)
OutputDebugStringA(strDbg.GetBuffer());
# endif
# if VTRACE_TO_CONSOLE
printf(strDbg.GetBuffer());
# endif // VTRACE_TO_CONSOLE
}

void CWDSTracer::operator()(LPCWSTR format, ...) // Unicode
void CWDSTracer::operator()(LPCWSTR format, ...) const
{
CStringW str;
va_list args;
Expand All @@ -108,20 +79,21 @@ void CWDSTracer::operator()(LPCWSTR format, ...) // Unicode
va_end(args);
CStringW strDbg, strPfx;
# if (VTRACE_DETAIL == VTRACE_FILE_LINE_FUNC)
strPfx.Format(L"%hs:%u|%hs", m_srcbasename, m_srcline, m_srcfunc);
strPfx.Format(L"%s:%u|%s", m_srcbasename, m_srcline, m_srcfunc);
# elif (VTRACE_DETAIL == VTRACE_FILE_LINE)
strPfx.Format(L"%hs:%u", m_srcbasename, m_srcline);
strPfx.Format(L"%s:%u", m_srcbasename, m_srcline);
# elif (VTRACE_DETAIL == VTRACE_FUNC)
strPfx = m_srcfunc;
# endif
if(strPfx.IsEmpty())
strDbg.Format(L"%ws\n", str.GetBuffer());
strDbg.Format(L"%s\n", str.GetBuffer());
else
strDbg.Format(L"[%ws] %ws\n", strPfx.GetBuffer(), str.GetBuffer());
strDbg.Format(L"[%s] %s\n", strPfx.GetBuffer(), str.GetBuffer());
# if !VTRACE_TO_CONSOLE || (VTRACE_TO_CONSOLE && !VTRACE_NO_OUTPUTDEBUGSTRING)
OutputDebugStringW(strDbg.GetBuffer());
# endif
# ifdef VTRACE_TO_CONSOLE
# if VTRACE_TO_CONSOLE
wprintf(strDbg.GetBuffer());
# endif // VTRACE_TO_CONSOLE
}
#endif
17 changes: 8 additions & 9 deletions common/Tracer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tracer.h - Implementation of tracer class for debugging purposes
// Tracer.h - Implementation of tracer class for debugging purposes
//
// NOTE: this file is under MIT license as opposed to the project as a whole.
//
Expand Down Expand Up @@ -47,19 +47,18 @@ class CWDSTracerConsole final
class CWDSTracer final
{
public:
CWDSTracer(LPCSTR srcfile, LPCSTR fctname, unsigned int srcline);
void operator()(LPCSTR format, ...);
void operator()(LPCWSTR format, ...);
CWDSTracer(LPCWSTR srcfile, LPCWSTR fctname, unsigned int srcline);
CWDSTracer& operator=(const CWDSTracer&) = delete; // hide it
void operator()(LPCWSTR format, ...) const;
private:
const CStringA m_srcfile;
const CStringW m_srcfile;
unsigned int m_srcline;
LPCSTR m_srcbasename;
LPCSTR m_srcfunc;
CWDSTracer& operator=(const CWDSTracer&) = delete; // hide it
LPCWSTR m_srcbasename;
LPCWSTR m_srcfunc;
};

// Use as VTRACE(format, ...) ... *must* be on one long line ;)
# define VTRACE CWDSTracer(__##FILE##__, __##FUNCTION##__, __##LINE##__)
# define VTRACE CWDSTracer(__##FILEW##__, __##FUNCTIONW__, __##LINE##__)
#else
# define VTRACE __noop
#endif // _DEBUG
1 change: 0 additions & 1 deletion premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ solution (iif(release, slnname, "windirstat"))

excludes
{
"common/tracer.cpp", -- this one gets an #include via windirstat.cpp
}

vpaths
Expand Down
6 changes: 3 additions & 3 deletions windirstat/BlockingQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BlockingQueue
std::condition_variable pushed;
std::condition_variable waiting;
std::condition_variable popped;
unsigned int m_initial_workers;
unsigned int m_initial_workers = 1;
unsigned int m_workers_waiting = 0;
bool m_started = false;
bool m_suspended = false;
Expand Down Expand Up @@ -111,7 +111,7 @@ class BlockingQueue
return m_suspended;
}

void suspend(bool wait)
void suspend(const bool wait)
{
std::unique_lock lock(x);
if (m_suspended || m_draining || !m_started) return;
Expand All @@ -131,7 +131,7 @@ class BlockingQueue
pushed.notify_all();
}

void reset(int initial_workers = -1)
void reset(const int initial_workers = -1)
{
std::lock_guard lock(x);
q.clear();
Expand Down
Loading

0 comments on commit 9700485

Please sign in to comment.