Skip to content

Commit

Permalink
Merge branch 'ms/master' into unc_path_support
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/wfgoto.cpp
#	src/wfinit.c
  • Loading branch information
schinagl committed Jun 7, 2024
2 parents 908c426 + e3075d5 commit ff5dd36
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 74 deletions.
22 changes: 20 additions & 2 deletions src/wfassoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2572,8 +2572,26 @@ FileTypeWrite(HWND hDlg,

Error:

if (IDD_CONFIG != pAssociateFileDlgInfo->mode) {
LocalFree((HLOCAL)pFileType);
// If creating a new file type
if (IDD_CONFIG != pAssociateFileDlgInfo->mode)
{
// Find any extensions pointing to it, remove them, and point them to
// any original file type if possible
PEXT pExt;
while (pFileType->pExt != NULL)
{
pExt = pFileType->pExt;
ExtDelink(pExt);
if (pExt->pftOrig != NULL) {
ExtLink(pExt, pExt->pftOrig);
}
// Indicate no update should occur for this extension
pExt->bAdd = FALSE;
pExt->bDelete = FALSE;
}

// Free the file type and any associated buffer
FileTypeFree(pFileType);
}
return dwError;
}
Expand Down
13 changes: 12 additions & 1 deletion src/wfgoto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,18 @@ SetCurrentPathOfWindow(LPWSTR szPath)
}
}
else
hwndNew = CreateDirWindow(szPath, TRUE, hwndActive);
{
TCHAR szFullPath[MAXPATHLEN];
LPTSTR szFilePart;

DWORD result = GetFullPathName(szPath, COUNTOF(szFullPath), szFullPath, &szFilePart);
if (result == 0 || result >= COUNTOF(szFullPath))
{
return;
}

hwndNew = CreateDirWindow(szFullPath, TRUE, hwndActive);
}

HWND hwndTree = HasTreeWindow(hwndNew);
if (hwndTree)
Expand Down
184 changes: 113 additions & 71 deletions src/wfinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,121 +760,163 @@ CheckDirExists(

BOOL
CreateSavedWindows(
LPCWSTR pszInitialDir
)
LPCWSTR pszInitialDir
)
{
WCHAR buf[2*MAXPATHLEN+7*7], key[10];
WCHAR buf[2 * MAXPATHLEN + 7 * 7], key[10];
WINDOW win;

//
// since win.szDir is bigger.
//
WCHAR szDir[2*MAXPATHLEN];
WCHAR szDir[2 * MAXPATHLEN];

INT nDirNum;
HWND hwnd;
INT iNumTrees;

//
// Initialize window geometry to use system default
//
win.rc.left = CW_USEDEFAULT;
win.rc.top = 0;
win.rc.right = win.rc.left + CW_USEDEFAULT;
win.rc.bottom = 0;
win.nSplit = -1;

win.dwView = dwNewView;
win.dwSort = dwNewSort;
win.dwAttribs = dwNewAttribs;

//
// make sure this thing exists so we don't hit drives that don't
// exist any more
//
nDirNum = 1;
iNumTrees = 0;
INT nDirNum = 1;
INT iNumTrees = 0;

if (pszInitialDir == NULL)
do
{
do
{
wsprintf(key, szDirKeyFormat, nDirNum++);

GetPrivateProfileString(szSettings, key, szNULL, buf, COUNTOF(buf), szTheINIFile);

if (*buf)
{
GetSavedWindow(buf, &win);

lstrcpy(szDir, win.szDir);
if (*buf) {

// clean off some junk so we can do this test
StripFilespec(szDir);
StripBackslash(szDir);
GetSavedWindow(buf, &win);

if (win.szRoot[0]) {
// UNC Drive
if (win.dwDriveNumber > -1 && win.dwDriveNumber < MAX_UNC)
SetUNCDrive(win.szRoot, OFFSET_UNC + win.dwDriveNumber);
else
AddUNCDrive(win.szRoot);
} else {
// In case of broken .ini file and UNC
if (ISUNCPATH(szDir))
AddUNCDrive(szDir);
}
if (pszInitialDir == NULL)
{
lstrcpy(szDir, win.szDir);

// clean off some junk so we can do this test
StripFilespec(szDir);
StripBackslash(szDir);

if (win.szRoot[0]) {
// UNC Drive
if (win.dwDriveNumber > -1 && win.dwDriveNumber < MAX_UNC)
SetUNCDrive(win.szRoot, OFFSET_UNC + win.dwDriveNumber);
else
AddUNCDrive(win.szRoot);
}
else {
// In case of broken .ini file and UNC
if (ISUNCPATH(szDir))
AddUNCDrive(szDir);
else {
//
// Winfile won't retain any relative paths in the INI file, but if
// one was provided externally, convert it into a full path
//
LPTSTR FilePart;
DWORD SizeAvailable = COUNTOF(win.szDir);
DWORD CharsCopied = GetFullPathName(szDir, SizeAvailable, win.szDir, &FilePart);
if (CharsCopied == 0 || CharsCopied >= SizeAvailable) {
continue;
}
lstrcpy(szDir, win.szDir);
}
}

if (!CheckDirExists(szDir)) {
continue;
if (!CheckDirExists(szDir)) {
continue;
}

AddBackslash(szDir);
lstrcat(szDir, szStarDotStar);
AddBackslash(szDir);
lstrcat(szDir, szStarDotStar);

dwNewView = win.dwView;
dwNewSort = win.dwSort;
dwNewAttribs = win.dwAttribs;
dwNewView = win.dwView;
dwNewSort = win.dwSort;
dwNewAttribs = win.dwAttribs;

hwnd = CreateTreeWindow(szDir,
win.rc.left,
win.rc.top,
win.rc.right - win.rc.left,
win.rc.bottom - win.rc.top,
win.nSplit);
hwnd = CreateTreeWindow(szDir,
win.rc.left,
win.rc.top,
win.rc.right - win.rc.left,
win.rc.bottom - win.rc.top,
win.nSplit);

if (!hwnd) {
continue;
}
if (!hwnd) {
continue;
}

iNumTrees++;
iNumTrees++;

//
// keep track of this for now...
//
//
// keep track of this for now...
//
if (IsIconic(hwnd)) {
SetWindowPos(hwnd, NULL, win.pt.x, win.pt.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
SetWindowPos(hwnd, NULL, win.pt.x, win.pt.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}

ShowWindow(hwnd, win.sw);
ShowWindow(hwnd, win.sw);
}
}

} while (*buf);
}

//
// If the user requested to open the program with a specific directory,
// open it
//

if (pszInitialDir != NULL){
if (pszInitialDir != NULL)
{
LPTSTR FilePart;
DWORD SizeAvailable = COUNTOF(buf) - (DWORD)wcslen(szStarDotStar) - 1;
DWORD CharsCopied = GetFullPathName(pszInitialDir, SizeAvailable, buf, &FilePart);
if (CharsCopied > 0 &&
CharsCopied < SizeAvailable &&
!ISUNCPATH(buf) &&
CheckDirExists(buf))
{
AddBackslash(buf);
lstrcat(buf, szStarDotStar);

lstrcpy(buf, pszInitialDir);
AddBackslash(buf);
lstrcat(buf, szStarDotStar);
//
// use the settings of the most recent window as defaults
//

//
// default to split window
//
hwnd = CreateTreeWindow(buf, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, -1);
dwNewView = win.dwView;
dwNewSort = win.dwSort;
dwNewAttribs = win.dwAttribs;

if (!hwnd)
return FALSE;
hwnd = CreateTreeWindow(buf,
win.rc.left,
win.rc.top,
win.rc.right - win.rc.left,
win.rc.bottom - win.rc.top,
win.nSplit);

//
// Default to maximized since the user requested to open a single
// directory
//
ShowWindow(hwnd, SW_MAXIMIZE);
if (!hwnd) {
return FALSE;
}

iNumTrees++;
//
// Default to maximized since the user requested to open a single
// directory
//
ShowWindow(hwnd, SW_MAXIMIZE);

iNumTrees++;
}
}

LoadUNCDrives();
Expand Down

0 comments on commit ff5dd36

Please sign in to comment.