From bf383b7e0cd4c04e6a7b9fe9bcbe6dc1190f90e5 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sun, 11 Sep 2022 20:57:22 +0200 Subject: [PATCH 01/14] UNC Name path handling --- src/lang/res_de-DE.rc | 2 +- src/lang/res_en-US.rc | 2 +- src/lang/res_he-IL.rc | 2 +- src/lang/res_ja-JP.rc | 60 +++--- src/lang/res_pl-PL.rc | 2 +- src/lang/res_tr-TR.rc | 2 +- src/lang/res_zh-CN.rc | 2 +- src/lang/winfile_de-DE.dlg | 2 +- src/lang/winfile_he-IL.dlg | 2 +- src/lang/winfile_ja-JP.dlg | 2 +- src/lang/winfile_pl-PL.dlg | 2 +- src/lang/winfile_tr-TR.dlg | 2 +- src/lang/winfile_zh-CN.dlg | 2 +- src/treectl.c | 429 ++++++++++++++++++++----------------- src/wfchgnot.c | 4 +- src/wfcomman.c | 25 ++- src/wfcopy.c | 12 +- src/wfcopy.h | 2 +- src/wfdir.c | 43 ++-- src/wfdirrd.c | 23 +- src/wfdlgs.c | 41 ++-- src/wfdlgs3.c | 10 +- src/wfdos.c | 10 +- src/wfdrives.c | 28 ++- src/wfgoto.cpp | 26 ++- src/wfinfo.c | 25 ++- src/wfinit.c | 45 ++-- src/wftree.c | 6 +- src/wfutil.c | 212 ++++++++++++------ src/winfile.h | 29 ++- 30 files changed, 649 insertions(+), 405 deletions(-) diff --git a/src/lang/res_de-DE.rc b/src/lang/res_de-DE.rc index 38c8eed0..fb88fc7d 100644 --- a/src/lang/res_de-DE.rc +++ b/src/lang/res_de-DE.rc @@ -285,7 +285,7 @@ BEGIN IDS_STATUSMSG, "%d Datei(en) (%s)" /* 128 */ IDS_STATUSMSG2, "%d Datei(en) (%s) ausgewählt" /* 128 */ - IDS_DRIVEFREE, "%c: %s von %s frei" /* 128 */ + IDS_DRIVEFREE, "%s %s von %s frei" /* 128 */ IDS_TREEABORT, "Unvollständiger Verzeichnisbaum wird angezeigt" /* 128 */ IDS_DIRSREAD, "%d Verzeichnisse gelesen" /* 32 */ IDS_SEARCHMSG, "%d Datei(en) gefunden" diff --git a/src/lang/res_en-US.rc b/src/lang/res_en-US.rc index fce54ab2..5dd70edb 100644 --- a/src/lang/res_en-US.rc +++ b/src/lang/res_en-US.rc @@ -287,7 +287,7 @@ BEGIN IDS_STATUSMSG, "Total %d file(s) (%s)" /* 128 */ IDS_STATUSMSG2, "Selected %d file(s) (%s)" /* 128 */ - IDS_DRIVEFREE, "%c: %s free, %s total" /* 128 */ + IDS_DRIVEFREE, "%s %s free, %s total" /* 128 */ IDS_TREEABORT, "Incomplete directory tree displayed" /* 128 */ IDS_DIRSREAD, "Directories read: %d " /* 32 */ IDS_SEARCHMSG, "%d file(s) found" diff --git a/src/lang/res_he-IL.rc b/src/lang/res_he-IL.rc index 36ff4a96..1beeedf7 100644 --- a/src/lang/res_he-IL.rc +++ b/src/lang/res_he-IL.rc @@ -287,7 +287,7 @@ BEGIN IDS_STATUSMSG, "סך הכל %d קבצים (%s)" /* 128 */ IDS_STATUSMSG2, "%d קבצים נבחרו (%s)" /* 128 */ - IDS_DRIVEFREE, "%c: %s פנוי, %s סך הכל" /* 128 */ + IDS_DRIVEFREE, "%s %s פנוי, %s סך הכל" /* 128 */ IDS_TREEABORT, "עץ התיקיות לא מוצג במלואו" /* 128 */ IDS_DIRSREAD, "תיקיות נקראו: %d " /* 32 */ IDS_SEARCHMSG, "%d קבצים נמצאו" diff --git a/src/lang/res_ja-JP.rc b/src/lang/res_ja-JP.rc index 0d9b1349..c1970ea2 100644 --- a/src/lang/res_ja-JP.rc +++ b/src/lang/res_ja-JP.rc @@ -14,14 +14,14 @@ BEGIN POPUP "ファイル(&F)" BEGIN MENUITEM "開く(&O)\tEnter", IDM_OPEN - MENUITEM "編集\tF12", IDM_EDIT + MENUITEM "編集\tF12", IDM_EDIT MENUITEM "移動(&M)...\tF7", IDM_MOVE MENUITEM "コピー(&C)...\tF8", IDM_COPY - MENUITEM "シンボリックリンク(&Y)...\tF11", IDM_SYMLINK - MENUITEM "ハードリンク(&K)...\tShift+F11", IDM_HARDLINK + MENUITEM "シンボリックリンク(&Y)...\tF11", IDM_SYMLINK + MENUITEM "ハードリンク(&K)...\tShift+F11", IDM_HARDLINK MENUITEM "クリップボードにコピー(&B)...\tCtrl+C", IDM_COPYTOCLIPBOARD - MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD - MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE + MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD + MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE MENUITEM "削除(&D)...\tDel", IDM_DELETE MENUITEM "名前の変更(&N)...", IDM_RENAME MENUITEM "プロパティ(&T)...\tAlt+Enter",IDM_ATTRIBS @@ -43,7 +43,7 @@ BEGIN MENUITEM "&PowerShell を起動...\tCtrl+P", IDM_STARTPOWERSHELL MENUITEM "&Explorer を起動...\tCtrl+E", IDM_STARTEXPLORER END - MENUITEM "別のディレクトリへ移動(&G)...\tCtrl+G", IDM_GOTODIR + MENUITEM "別のディレクトリへ移動(&G)...\tCtrl+G", IDM_GOTODIR MENUITEM SEPARATOR MENUITEM "終了(&X)", IDM_EXIT END @@ -91,10 +91,10 @@ BEGIN MENUITEM "フォント(&F)...", IDM_FONT MENUITEM "ツール バーのカスタマイズ(&B)...", IDM_TOOLBARCUST MENUITEM "追加の設定(&P)", IDM_PREF - MENUITEM SEPARATOR - MENUITEM "ツール バー(&T)", IDM_TOOLBAR - MENUITEM "ドライブ バー(&D)", IDM_DRIVEBAR - MENUITEM "ステータス バー(&S)", IDM_STATUSBAR + MENUITEM SEPARATOR + MENUITEM "ツール バー(&T)", IDM_TOOLBAR + MENUITEM "ドライブバー(&D)", IDM_DRIVEBAR + MENUITEM "ステータスバー(&S)", IDM_STATUSBAR MENUITEM SEPARATOR MENUITEM "プログラムの起動時に最小化(&M)", IDM_MINONRUN MENUITEM "起動時に移動先インデックスを作成(&G)", IDM_INDEXONLAUNCH @@ -132,28 +132,28 @@ END CTXMENU MENU BEGIN - POPUP "Dummy Popup" - BEGIN - MENUITEM "新しいウィンドウ(&N)\tCtrl+Shift Enter", IDM_NEWWINDOW + POPUP "Dummy Popup" + BEGIN + MENUITEM "新しいウィンドウ(&N)\tCtrl+Shift Enter", IDM_NEWWINDOW MENUITEM "開く(&O)\tEnter", IDM_OPEN - MENUITEM "編集\tF12", IDM_EDIT + MENUITEM "編集\tF12", IDM_EDIT MENUITEM "移動(&M)...\tF7", IDM_MOVE MENUITEM "コピー(&C)...\tF8", IDM_COPY MENUITEM "シンボリックリンク(&Y)...\tF11", IDM_SYMLINK MENUITEM "ハードリンク(&K)...\tShift+F11", IDM_HARDLINK - MENUITEM "クリップボードにコピー(&B)\tCtrl+C", IDM_COPYTOCLIPBOARD - MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD - MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE - MENUITEM "削除(&D)...\tDel", IDM_DELETE + MENUITEM "クリップボードにコピー(&B)\tCtrl+C", IDM_COPYTOCLIPBOARD + MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD + MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE + MENUITEM "削除(&D)...\tDel", IDM_DELETE MENUITEM "名前の変更(&N)...\tF2", IDM_RENAME MENUITEM "プロパティ(&T)...\tAlt+Enter",IDM_ATTRIBS MENUITEM "実行(&R)...", IDM_RUN MENUITEM "Bash を起動...", IDM_STARTBASHSHELL - MENUITEM "コマンド プロンプトを起動(&L)...", IDM_STARTCMDSHELL - MENUITEM "PowerShell を起動(&W)...", IDM_STARTPOWERSHELL + MENUITEM "コマンド プロンプトを起動(&L)...", IDM_STARTCMDSHELL + MENUITEM "PowerShell を起動(&W)...", IDM_STARTPOWERSHELL MENUITEM "Explorer を起動(&X)...", IDM_STARTEXPLORER - MENUITEM "別のディレクトリへ移動(&G)...", IDM_GOTODIR - END + MENUITEM "別のディレクトリへ移動(&G)...", IDM_GOTODIR + END END @@ -200,7 +200,7 @@ BEGIN IDS_LABELDISKERR "ファイル マネージャーはフロッピー ディスクにボリューム ラベルを付けられません。\n\nフロッピー ディスクが書き込み禁止になっていない事、ネットワーク ドライブではない事を確認して、正しい名前を入力して下さい。\n名前には次の文字を含めることはできません:\n[空白] * ? / \\ | . , ; : + = [ ] ( ) & ^ < > "" " - IDS_SEARCHNOMATCHES "一致するファイルが見つかりませんでした。" + IDS_SEARCHNOMATCHES "一致するファイルが見つかりませんでした。" IDS_SEARCHREFRESH "このドライブの内容が変更されました。検索を再度実行しますか?" IDS_LABELACCESSDENIED "この操作をハード ディスク上で実行するには、このワークステーションに管理者としてログインする必要があります。" @@ -258,10 +258,10 @@ BEGIN IDS_SYMLINK, "シンボリックリンク" /* 32 */ IDS_HARDLINK, "ハードリンク" /* 32 */ - IDS_KK_COPYFROMSTR, "コピー元(&F):" - IDS_KK_COPYTOSTR, "コピー先(&T):" - IDS_KK_RENAMEFROMSTR, "元の名前(&F):" - IDS_KK_RENAMETOSTR, "新しい名前(&T):" + IDS_KK_COPYFROMSTR, "コピー元(&F):" + IDS_KK_COPYTOSTR, "コピー先(&T):" + IDS_KK_RENAMEFROMSTR, "元の名前(&F):" + IDS_KK_RENAMETOSTR, "新しい名前(&T):" IDS_KK_HARDLINKFROMSTR, "ハードリンク元(&F):" IDS_KK_HARDLINKTOSTR, "ハードリンク先(&T):" IDS_KK_SYMLINKFROMSTR, "シンボリックリンク元(&F):" @@ -286,7 +286,7 @@ BEGIN IDS_STATUSMSG, "合計 %d 個のファイル (%s)" /* 128 */ IDS_STATUSMSG2, "%d 個のファイルを選択 (%s)" /* 128 */ - IDS_DRIVEFREE, "%c: %s 使用可能(合計 %s)" /* 128 */ + IDS_DRIVEFREE, "%s %s 使用可能(合計 %s)" /* 128 */ IDS_TREEABORT, "ディレクトリ ツリーの表示が不完全" /* 128 */ IDS_DIRSREAD, "ディレクトリの読み込み: %d" /* 32 */ IDS_SEARCHMSG, "%d 個のファイルが見つかりました" @@ -547,8 +547,8 @@ BEGIN MH_MYITEMS+IDM_MOVE, "選択アイテムを移動する" MH_MYITEMS+IDM_COPY, "ファイルまたはディレクトリをコピーする" MH_MYITEMS+IDM_COPYTOCLIPBOARD, "1つまたは複数のファイルをクリップボードにコピーする" - MH_MYITEMS+IDM_CUTTOCLIPBOARD, "1つまたは複数のファイルをクリップボードに切り取る" - MH_MYITEMS+IDM_PASTE, "現在のディレクトリにクリップボードから貼り付ける" + MH_MYITEMS+IDM_CUTTOCLIPBOARD, "1つまたは複数のファイルをクリップボードに切り取る" + MH_MYITEMS+IDM_PASTE, "現在のディレクトリにクリップボードから貼り付ける" MH_MYITEMS+IDM_COMPRESS, "ファイルまたはディレクトリを圧縮する" MH_MYITEMS+IDM_UNCOMPRESS, "ファイルまたはディレクトリを解凍する" MH_MYITEMS+IDM_DELETE, "ファイルまたはディレクトリを削除する" diff --git a/src/lang/res_pl-PL.rc b/src/lang/res_pl-PL.rc index 29481ed5..9b3f7d2e 100644 --- a/src/lang/res_pl-PL.rc +++ b/src/lang/res_pl-PL.rc @@ -287,7 +287,7 @@ BEGIN IDS_STATUSMSG, "Razem plików: %d (%s)" /* 128 */ IDS_STATUSMSG2, "Wybrano: %d plik(ów) (%s)" /* 128 */ - IDS_DRIVEFREE, "Wolne: %c:%s: razem: %s" /* 128 */ + IDS_DRIVEFREE, "Wolne: %s %s: razem: %s" /* 128 */ IDS_TREEABORT, "Wyświetlono niepełne drzewo katalogów" /* 128 */ IDS_DIRSREAD, "Katalogi przeczytane: %d " /* 32 */ IDS_SEARCHMSG, "Znaleziono: %d plik(ów)" diff --git a/src/lang/res_tr-TR.rc b/src/lang/res_tr-TR.rc index e485f37d..7da23a92 100644 --- a/src/lang/res_tr-TR.rc +++ b/src/lang/res_tr-TR.rc @@ -272,7 +272,7 @@ BEGIN IDS_UNFORMATTED, "%c sürücüsündeki disk biçimlendirilmemiş.\n\nŞimdi biçimlendirmek istiyor musunuz?" IDS_STATUSMSG, "Toplam %d dosya (%s bayt)" IDS_STATUSMSG2, "%d dosya seçili (%s bayt)" - IDS_DRIVEFREE, "%c: %s boş, toplam %s" + IDS_DRIVEFREE, "%s %s boş, toplam %s" IDS_TREEABORT, "Görüntülenen dizin ağacı eksik." IDS_DIRSREAD, "Okunan dizin sayısı: %d " IDS_SEARCHMSG, "%d dosya bulundu." diff --git a/src/lang/res_zh-CN.rc b/src/lang/res_zh-CN.rc index d9dc933c..8aad3680 100644 --- a/src/lang/res_zh-CN.rc +++ b/src/lang/res_zh-CN.rc @@ -284,7 +284,7 @@ BEGIN IDS_STATUSMSG, "共 %d 个文件 (%s)" /* 128 */ IDS_STATUSMSG2, "选择了 %d 个文件 (%s)" /* 128 */ - IDS_DRIVEFREE, "%c: %s 可用空间,%s 全部空间" /* 128 */ + IDS_DRIVEFREE, "%s %s 可用空间,%s 全部空间" /* 128 */ IDS_TREEABORT, "目录树未完整显示" /* 128 */ IDS_DIRSREAD, "目录读取: %d" /* 32 */ IDS_SEARCHMSG, "找到 %d 个文件" diff --git a/src/lang/winfile_de-DE.dlg b/src/lang/winfile_de-DE.dlg index b33be9d7..b4f3c298 100644 --- a/src/lang/winfile_de-DE.dlg +++ b/src/lang/winfile_de-DE.dlg @@ -89,7 +89,7 @@ FONT 8, "MS Shell Dlg" STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME | WS_POPUP BEGIN CONTROL "&Datenträger:", IDD_DRIVE1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 5, 41, 10 - CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_SORT | LBS_STANDARD | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 + CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 CONTROL "OK", IDOK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 6, 40, 14 CONTROL "Abbrechen", IDCANCEL, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 23, 40, 14 CONTROL "&Hilfe", IDD_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 44, 40, 14 diff --git a/src/lang/winfile_he-IL.dlg b/src/lang/winfile_he-IL.dlg index c47a69fc..4898c355 100644 --- a/src/lang/winfile_he-IL.dlg +++ b/src/lang/winfile_he-IL.dlg @@ -96,7 +96,7 @@ STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME | WS_POP EXSTYLE WS_EX_LAYOUTRTL BEGIN CONTROL "&כוננים:", IDD_DRIVE1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 5, 41, 10 - CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_SORT | LBS_STANDARD | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 + CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 CONTROL "אישור", IDOK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 6, 40, 14 CONTROL "ביטול", IDCANCEL, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 23, 40, 14 CONTROL "&עזרה", IDD_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 44, 40, 14 diff --git a/src/lang/winfile_ja-JP.dlg b/src/lang/winfile_ja-JP.dlg index 443f4cca..3154ea7a 100644 --- a/src/lang/winfile_ja-JP.dlg +++ b/src/lang/winfile_ja-JP.dlg @@ -92,7 +92,7 @@ FONT 8, "MS Shell Dlg" STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME | WS_POPUP BEGIN CONTROL "ドライブ(&D):", IDD_DRIVE1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 5, 41, 10 - CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_SORT | LBS_STANDARD | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 + CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 CONTROL "OK", IDOK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 6, 40, 14 CONTROL "キャンセル", IDCANCEL, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 23, 40, 14 CONTROL "ヘルプ(&H)", IDD_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 44, 40, 14 diff --git a/src/lang/winfile_pl-PL.dlg b/src/lang/winfile_pl-PL.dlg index 223a074c..e892f22b 100644 --- a/src/lang/winfile_pl-PL.dlg +++ b/src/lang/winfile_pl-PL.dlg @@ -92,7 +92,7 @@ FONT 8, "MS Shell Dlg" STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME | WS_POPUP BEGIN CONTROL "&Dyski:", IDD_DRIVE1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 5, 41, 10 - CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_SORT | LBS_STANDARD | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 + CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 CONTROL "OK", IDOK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 6, 40, 14 CONTROL "Anuluj", IDCANCEL, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 23, 40, 14 CONTROL "Pomo&c", IDD_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 44, 40, 14 diff --git a/src/lang/winfile_tr-TR.dlg b/src/lang/winfile_tr-TR.dlg index 39802d16..dbc8ba1e 100644 --- a/src/lang/winfile_tr-TR.dlg +++ b/src/lang/winfile_tr-TR.dlg @@ -92,7 +92,7 @@ FONT 8, "MS Shell Dlg" STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME | WS_POPUP BEGIN CONTROL "&Sürücüler:", IDD_DRIVE1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 5, 41, 10 - CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_SORT | LBS_STANDARD | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 + CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 CONTROL "Tamam", IDOK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 6, 40, 14 CONTROL "İptal", IDCANCEL, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 23, 40, 14 CONTROL "&Yardım", IDD_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 44, 40, 14 diff --git a/src/lang/winfile_zh-CN.dlg b/src/lang/winfile_zh-CN.dlg index 0da903dc..ba51b18d 100644 --- a/src/lang/winfile_zh-CN.dlg +++ b/src/lang/winfile_zh-CN.dlg @@ -92,7 +92,7 @@ FONT 8, "MS Shell Dlg" STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME | WS_POPUP BEGIN CONTROL "驱动器(&D):", IDD_DRIVE1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 5, 41, 10 - CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_SORT | LBS_STANDARD | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 + CONTROL "", IDD_DRIVE, "listbox", LBS_NOTIFY | LBS_USETABSTOPS | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_TABSTOP, 5, 16, 140, 60 CONTROL "确定", IDOK, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 6, 40, 14 CONTROL "取消", IDCANCEL, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 23, 40, 14 CONTROL "帮助(&H)", IDD_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 155, 44, 40, 14 diff --git a/src/treectl.c b/src/treectl.c index ca244130..f913503e 100644 --- a/src/treectl.c +++ b/src/treectl.c @@ -80,8 +80,8 @@ FindItemFromPath( HWND hwndLB, LPTSTR lpszPath, BOOL bReturnParent, - DWORD *pIndex, - PDNODE *ppNode); + DWORD *pIndex, + PDNODE *ppNode); INT BuildTreeName( @@ -176,7 +176,7 @@ GetTreePath(PDNODE pNode, LPTSTR szDest) // SetNodeAttribs -// +// // Set node attributes for directory/junction/symlink // VOID @@ -189,7 +189,7 @@ SetNodeAttribs(PDNODE pNode, LPTSTR szPath) // // Determine which kind of Reparse Point - // + // if (pNode->dwAttribs & ATTR_REPARSE_POINT) { TCHAR szTemp[MAXPATHLEN]; @@ -425,7 +425,7 @@ InsertDirectory( } else { - int iCmp; + int iCmp; do { iMid = (iMax + iMin) / 2; @@ -804,6 +804,7 @@ ReadDirLevel( iNode, dwAttribs, bFullyExpand, szAutoExpand, bPartialSort); } + BOOL bCasePreserved = IsCasePreservedDrive(DRIVEID(szPath)); while (bFound) { if (uYieldCount & (1<nLevels + 1, nIndex, dwAttribs, FALSE, szExpand, FALSE)) { - SPC_SET_NOTREE(qFreeSpace); - } + if (!ReadDirLevel(hwndTC, pNode, szExists, pNode->nLevels + 1, nIndex, dwAttribs, FALSE, szExpand, FALSE)) { + SPC_SET_NOTREE(qFreeSpace); + } - if (FindItemFromPath(hwndLB, szDir, FALSE, NULL, &pNode)) { - // found desired path in newly expanded list; select - SendMessage(hwndLB, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)pNode); - } + if (FindItemFromPath(hwndLB, szDir, FALSE, NULL, &pNode)) { + // found desired path in newly expanded list; select + SendMessage(hwndLB, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)pNode); + } - UpdateStatus(GetParent(hwndTC)); // Redraw the Status Bar + UpdateStatus(GetParent(hwndTC)); // Redraw the Status Bar - SendMessage(hwndLB, WM_SETREDRAW, TRUE, 0L); + SendMessage(hwndLB, WM_SETREDRAW, TRUE, 0L); - InvalidateRect(hwndLB, NULL, TRUE); - UpdateWindow(hwndLB); // make this look a bit better + InvalidateRect(hwndLB, NULL, TRUE); + UpdateWindow(hwndLB); // make this look a bit better } + +// +// MatchNode() +// +// Find the PDNODE and LBIndex for a path element +// +// returns: +// TRUE if found match; FALSE if out of items +// +BOOL MatchNode( + HWND hwndLB, + LPTSTR lpszElement, + DWORD *dwIndex, + DWORD *dwPreviousNode, + PDNODE *ppPreviousNode +) +{ + PDNODE pNode; + BOOL bReturn = TRUE; + + while (TRUE) { + // Out of LB items? Not found. + if (SendMessage(hwndLB, LB_GETTEXT, *dwIndex, (LPARAM)&pNode) == LB_ERR) { + bReturn = FALSE; + break; + } + + if (pNode->pParent == *ppPreviousNode) { + if (!lstrcmpi(lpszElement, pNode->szName)) { + // We've found the element, but we are not at the end of the path + *dwPreviousNode = *dwIndex; + *ppPreviousNode = pNode; + break; + } + } + (*dwIndex)++; + } + + return bReturn; +} + // // FindItemFromPath() // @@ -1328,116 +1383,99 @@ FindItemFromPath( HWND hwndLB, LPTSTR lpszPath, BOOL bReturnParent, - DWORD *pIndex, - PDNODE *ppNode) + DWORD* pIndex, + PDNODE* ppNode) { - DWORD i; - LPTSTR p; - PDNODE pNode; - DWORD iPreviousNode; - PDNODE pPreviousNode; - TCHAR szElement[1+MAXFILENAMELEN+1]; - - if (pIndex) - { + DWORD dwIndex; + LPTSTR p; + PDNODE pNode; + DWORD iPreviousNode; + PDNODE pPreviousNode; + TCHAR szElement[1 + MAXFILENAMELEN + 1]; + BOOL bReturn = TRUE; + + if (pIndex) { *pIndex = (DWORD)-1; - } - if (ppNode) - { + } + if (ppNode) { *ppNode = NULL; - } + } - if (!lpszPath || lstrlen(lpszPath) < 3 || lpszPath[1] != CHAR_COLON) - { + if (!lpszPath || lstrlen(lpszPath) < 3 || !((lpszPath[1] == CHAR_COLON) || lpszPath[1] == CHAR_BACKSLASH)) { return FALSE; - } - - i = 0; - iPreviousNode = (DWORD)-1; - pPreviousNode = NULL; - - while (*lpszPath) - { - /* NULL out szElement[1] so the backslash hack isn't repeated with - * a first level directory of length 1. - */ - szElement[1] = CHAR_NULL; - - /* Copy the next section of the path into 'szElement' */ - p = szElement; - - while (*lpszPath && *lpszPath != CHAR_BACKSLASH) - *p++ = *lpszPath++; + } - /* Add a backslash for the Root directory. */ + dwIndex = 0; + iPreviousNode = (DWORD)-1; + pPreviousNode = NULL; - if (szElement[1] == CHAR_COLON) - *p++ = CHAR_BACKSLASH; + // Retrieve the name of the root, which is always on index 0 + if (SendMessage(hwndLB, LB_GETTEXT, 0, (LPARAM)&pNode) != LB_ERR) { - /* NULL terminate 'szElement' */ - *p = CHAR_NULL; + // Is the root node a subnode of lpszPath + if (StrStrI(lpszPath, pNode->szName)) { + lstrcpy(szElement, pNode->szName); + // move lpszPath at the end of the + lpszPath += lstrlen(szElement); - /* Skip over the path's next Backslash. */ + do { + bReturn = MatchNode(hwndLB, szElement, &dwIndex, &iPreviousNode, &pPreviousNode); + + /* NULL out szElement[1] so the backslash hack isn't repeated with + * a first level directory of length 1. + */ + szElement[1] = CHAR_NULL; + + // Copy the next section of the path into 'szElement' and terminate it + p = szElement; + while (*lpszPath && *lpszPath != CHAR_BACKSLASH) + *p++ = *lpszPath++; + *p = CHAR_NULL; + + // Skip over the path's next Backslash. + if (*lpszPath) + lpszPath++; + else + if (bReturnParent) { + /* We're at the end of a path which includes a filename. Return + * the previously found parent. + */ + if (pIndex) { + *pIndex = iPreviousNode; + } + if (ppNode) { + *ppNode = pPreviousNode; + } + return TRUE; + } - if (*lpszPath) - lpszPath++; + // Break through the loops + if (!bReturn) + break; - else if (bReturnParent) - { - /* We're at the end of a path which includes a filename. Return - * the previously found parent. - */ - if (pIndex) { - *pIndex = iPreviousNode; - } - if (ppNode) { - *ppNode = pPreviousNode; - } - return TRUE; - } + } while (*lpszPath); - while (TRUE) - { - /* Out of LB items? Not found. */ - if (SendMessage(hwndLB, LB_GETTEXT, i, (LPARAM)&pNode) == LB_ERR) - { - if (pIndex) - { - *pIndex = iPreviousNode; - } - if (ppNode) - { - *ppNode = pPreviousNode; - } - return FALSE; - } + bReturn = MatchNode(hwndLB, szElement, &dwIndex, &iPreviousNode, &pPreviousNode); + } + else { + // e.g. drive change, when root node is different than lpszPath + bReturn = FALSE; + } + } + else + // uuups no root node. We should never get there + bReturn = FALSE; - if (pNode->pParent == pPreviousNode) - { - if (!lstrcmpi(szElement, pNode->szName)) - { - /* We've found the element... */ - iPreviousNode = i; - pPreviousNode = pNode; - break; - } - } - i++; - } - } - if (pIndex) - { + if (pIndex) { *pIndex = iPreviousNode; - } - if (ppNode) - { + } + if (ppNode) { *ppNode = pPreviousNode; - } + } - return TRUE; + return bReturn; } - /*--------------------------------------------------------------------------*/ /* */ /* RectTreeItem() - */ @@ -2119,7 +2157,7 @@ TreeControlWndProc( switch (uMsg) { case FS_GETDRIVE: - return (GetWindowLongPtr(hwndParent, GWL_TYPE) + L'A'); + return GetWindowLongPtr(hwndParent, GWL_TYPE) + CHAR_A; case TC_COLLAPSELEVEL: { @@ -2229,54 +2267,54 @@ TreeControlWndProc( DWORD i; if (FindItemFromPath(hwndLB, (LPTSTR)lParam, wParam != 0, &i, NULL)) - { - SendMessage(hwndLB, LB_SETCURSEL, i, 0L); - - // update dir window if it exists (which also updates MDI text) - SendMessage(hwnd, - WM_COMMAND, - GET_WM_COMMAND_MPS(IDCW_TREELISTBOX, - hwndLB, - LBN_SELCHANGE)); - } + { + SendMessage(hwndLB, LB_SETCURSEL, i, 0L); + + // update dir window if it exists (which also updates MDI text) + SendMessage(hwnd, + WM_COMMAND, + GET_WM_COMMAND_MPS(IDCW_TREELISTBOX, + hwndLB, + LBN_SELCHANGE)); + } break; } case TC_SETDRIVE: { -#define fFullyExpand LOBYTE(wParam) -#define fDontSteal HIBYTE(wParam) -#define fDontSelChange HIWORD(wParam) -#define szDir (LPTSTR)lParam // NULL -> default == window text. + INT fFullyExpand = LOBYTE(wParam); + INT fDontSteal = HIBYTE(wParam); + INT fDontSelChange = HIWORD(wParam); + LPTSTR szDir = (LPTSTR)lParam; // NULL -> default == window text. - // - // Don't do anything while the tree is being built. - // - if (GetWindowLongPtr(hwnd, GWL_READLEVEL)) - break; + // + // Don't do anything while the tree is being built. + // + if (GetWindowLongPtr(hwnd, GWL_READLEVEL)) + break; - RECT rc; - DWORD i; - PDNODE pNode; + RECT rc; + DWORD i; + PDNODE pNode; - // do the same as TC_SETDIRECTORY above for the simple case - if (FindItemFromPath(hwndLB, (LPTSTR)lParam, 0, &i, &pNode)) - { - // found exact node already displayed; select it and continue - SendMessage(hwndLB, LB_SETCURSEL, i, 0L); + // do the same as TC_SETDIRECTORY above for the simple case + if (FindItemFromPath(hwndLB, (LPTSTR)lParam, 0, &i, &pNode)) + { + // found exact node already displayed; select it and continue + SendMessage(hwndLB, LB_SETCURSEL, i, 0L); - goto UpdateDirSelection; - } + goto UpdateDirSelection; + } - if (!fFullyExpand && pNode) - { - // expand in place if pNode != null; index (i) also set - FillOutTreeList(hwnd, szDir, i, pNode); + if (!fFullyExpand && pNode) + { + // expand in place if pNode != null; index (i) also set + FillOutTreeList(hwnd, szDir, i, pNode); - goto UpdateDirSelection; - } + goto UpdateDirSelection; + } - // else change drive (existing code) + // else change drive (existing code) // // is the drive/dir specified? @@ -2290,10 +2328,8 @@ TreeControlWndProc( (LPARAM)szPath); StripBackslash(szPath); } - - CharUpperBuff(szPath, 1); // make sure - - SetWindowLongPtr(hwndParent, GWL_TYPE, szPath[0] - TEXT('A')); + + SetWindowLongPtr(hwndParent, GWL_TYPE, DRIVEID(szPath)); // // resize for new vol label @@ -2320,10 +2356,6 @@ TreeControlWndProc( LBN_SELCHANGE)); } break; -#undef fFullyExpand -#undef fDontSteal -#undef fDontSelChange -#undef szDir } case WM_CHARTOITEM: @@ -2360,7 +2392,7 @@ TreeControlWndProc( cchMatch = wcslen(rgchMatch); if (cchMatch > wcslen(pNode->szName)) cchMatch = wcslen(pNode->szName); - if (CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE, + if (CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE, rgchMatch, (INT)cchMatch, pNode->szName, (INT)cchMatch) == 2) break; @@ -2385,7 +2417,7 @@ TreeControlWndProc( } { IDropTarget *pDropTarget; - + pDropTarget = (IDropTarget *)GetWindowLongPtr(hwnd, GWL_OLEDROP); if (pDropTarget != NULL) UnregisterDropWindow(hwnd, pDropTarget); @@ -2415,7 +2447,7 @@ TreeControlWndProc( { WF_IDropTarget *pDropTarget; - + RegisterDropWindow(hwnd, &pDropTarget); SetWindowLongPtr(hwnd, GWL_OLEDROP, (LPARAM)pDropTarget); } @@ -2434,11 +2466,11 @@ TreeControlWndProc( if (!lParam || wParam == FSC_REFRESH) break; - /* Did we find it? */ - if (!FindItemFromPath(hwndLB, (LPTSTR)lParam, - wParam == FSC_MKDIR || wParam == FSC_MKDIRQUIET, (DWORD*)&nIndex, &pNode)) { + /* Did we find it? */ + if (!FindItemFromPath(hwndLB, (LPTSTR)lParam, + wParam == FSC_MKDIR || wParam == FSC_MKDIRQUIET, (DWORD*)&nIndex, &pNode)) { break; - } + } lstrcpy(szPath, (LPTSTR)lParam); StripPath(szPath); @@ -2630,7 +2662,7 @@ TreeControlWndProc( SendMessage(hwndDir, FS_CHANGEDISPLAY, id, (LPARAM)szPath); } else { - // TODO: why isn't this part of TC_SETDRIVE? currently when a tree only is shown, the MDI window text is not updated + // TODO: why isn't this part of TC_SETDRIVE? currently when a tree only is shown, the MDI window text is not updated SetMDIWindowText(hwndParent, szPath); } @@ -2676,8 +2708,8 @@ TreeControlWndProc( } case WM_CONTEXTMENU: - ActivateCommonContextMenu(hwnd, hwndLB, lParam); - break; + ActivateCommonContextMenu(hwnd, hwndLB, lParam); + break; case WM_LBTRACKPOINT: { @@ -2910,7 +2942,7 @@ TreeControlWndProc( } } } - else if (GetKeyState(VK_MENU) < 0 || GetKeyState(VK_SHIFT) < 0) + else if (GetKeyState(VK_MENU) < 0 || GetKeyState(VK_SHIFT) < 0) // ALT || SHIFT forces a move even if not on same drive iOperation = DROP_MOVE; else @@ -3267,11 +3299,14 @@ TreeControlWndProc( INT BuildTreeName(LPTSTR lpszPath, INT iLen, INT iSize) { - DRIVE drive = DRIVEID(lpszPath); - + // Check for \\ aka UNC + if (!ISUNCPATH(lpszPath)) + // Check for X:\ if (3 != iLen || CHAR_BACKSLASH != lpszPath[2]) return iLen; + DRIVE drive = DRIVEID(lpszPath); + lstrcat(lpszPath, SZ_FILESYSNAMESEP); iLen = lstrlen(lpszPath); diff --git a/src/wfchgnot.c b/src/wfchgnot.c index 16405469..9d06c2bb 100644 --- a/src/wfchgnot.c +++ b/src/wfchgnot.c @@ -179,7 +179,7 @@ NotifyReset() // // INC -- drive -2 == ALL // -1 == All of type uType -// 0 < drive < 26 is the drive to stop +// 0 < drive < MAX_DRIVES is the drive to stop // INC -- uType Type of drive to stop notification on // // @@ -239,7 +239,7 @@ NotifyPause(DRIVE drive, UINT uType) // Synopsis: Resume all notifications // // INC -- drive -1 == ALL -// 0 < drive < 26 is the drive to stop +// 0 < drive < MAX_DRIVES is the drive to stop // INC -- uType Type of drive to stop notification on // // Return: VOID diff --git a/src/wfcomman.c b/src/wfcomman.c index fec22e9c..cdcf2066 100644 --- a/src/wfcomman.c +++ b/src/wfcomman.c @@ -41,8 +41,7 @@ NotifySearchFSC( if (!hwndSearch) return; - if (DRIVEID(pszPath) == - SendMessage(hwndSearch, FS_GETDRIVE, 0, 0L) - CHAR_A) { + if (DRIVEID(pszPath) == SendMessage(hwndSearch, FS_GETDRIVE, 0, 0L) - CHAR_A) { SendMessage(hwndSearch, WM_FSC, dwFunction, 0L); } @@ -532,10 +531,8 @@ CreateDirWindow( // Are we replacing the contents of the currently active child? // if (bReplaceOpen) { - CharUpperBuff(szPath, 1); // make sure - DRIVE drive = DRIVEID(szPath); - for (INT i = 0; i= CHAR_A && pOrig[0] <= CHAR_Z) && - !(pOrig[0] >= CHAR_a && pOrig[0] <= TEXT('z')) ) { + !(pOrig[0] >= CHAR_a && pOrig[0] <= CHAR_z) ) { // // Invalid drive string; return FALSE! @@ -375,7 +375,7 @@ JAPANEND } if (CHAR_BACKSLASH == pOrig[0]) { - lpszPath[0] = (TCHAR)drive + (TCHAR)'A'; + lpszPath[0] = (TCHAR)drive + CHAR_A; lpszPath[1] = CHAR_COLON; lpszPath[2] = CHAR_BACKSLASH; lpszPath[3] = CHAR_NULL; @@ -704,7 +704,7 @@ IsTheDiskReallyThere( STKCHK(); - if (pPath[1]==CHAR_COLON) + if (pPath[1] == CHAR_COLON || ISUNCPATH(pPath)) drive = DRIVEID(pPath); else return 1; @@ -717,7 +717,7 @@ IsTheDiskReallyThere( LoadString(hAppInstance, IDS_COPYERROR + FUNC_SETDRIVE, szTitle, COUNTOF(szTitle)); - wsprintf(szMessage, szTemp, drive + CHAR_A); + wsprintf(szMessage, szTemp, DRIVESET_UC(drive)); MessageBox(hwnd, szMessage, szTitle, MB_ICONHAND); return 0; @@ -794,7 +794,7 @@ IsTheDiskReallyThere( // LoadString(hAppInstance, IDS_COPYERROR + dwFunc, szTitle, COUNTOF(szTitle)); LoadString(hAppInstance, IDS_DRIVENOTREADY, szTemp, COUNTOF(szTemp)); - wsprintf(szMessage, szTemp, drive + CHAR_A); + wsprintf(szMessage, szTemp, DRIVESET_UC(drive)); if (MessageBox(hwnd, szMessage, szTitle, MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY) goto Retry; else @@ -815,7 +815,7 @@ IsTheDiskReallyThere( if (!CancelInfo.hCancelDlg && IsRemovableDrive(drive)) { LoadString(hAppInstance, IDS_UNFORMATTED, szTemp, COUNTOF(szTemp)); - wsprintf(szMessage, szTemp, drive + CHAR_A); + wsprintf(szMessage, szTemp, DRIVESET_UC(drive)); if (MessageBox(hwnd, szMessage, szTitle, MB_ICONEXCLAMATION| MB_YESNO) == IDYES) { diff --git a/src/wfcopy.h b/src/wfcopy.h index 21a4f79c..061575e4 100644 --- a/src/wfcopy.h +++ b/src/wfcopy.h @@ -39,7 +39,7 @@ typedef struct _copyroot { WORD cDepth; LPTSTR pSource; LPTSTR pRoot; - TCHAR cIsDiskThereCheck[26]; + TCHAR cIsDiskThereCheck[MAX_DRIVES]; TCHAR sz[MAXPATHLEN]; TCHAR szDest[MAXPATHLEN]; LFNDTA rgDTA[MAXDIRDEPTH]; diff --git a/src/wfdir.c b/src/wfdir.c index e2670222..140812c4 100644 --- a/src/wfdir.c +++ b/src/wfdir.c @@ -377,10 +377,10 @@ CreateLBLine(DWORD dwLineFormat, LPXDTA lpxdta, LPWSTR szBuffer) } else { - pch += PutSize(&lpxdta->qFileSize, pch); - } + pch += PutSize(&lpxdta->qFileSize, pch); } } + } // // Should we show the date? @@ -883,8 +883,8 @@ DirWndProc( break; case WM_CONTEXTMENU: - ActivateCommonContextMenu(hwnd, hwndLB, lParam); - break; + ActivateCommonContextMenu(hwnd, hwndLB, lParam); + break; case WM_VKEYTOITEM: switch (GET_WM_VKEYTOITEM_CODE(wParam, lParam)) { @@ -893,10 +893,10 @@ DirWndProc( TypeAheadString('\0', NULL); return -2L; - case 'A': /* Ctrl-A */ - if (GetKeyState(VK_CONTROL) >= 0) - break; - case 0xBF: /* Ctrl-/ */ + case 'A': /* Ctrl-A */ + if (GetKeyState(VK_CONTROL) >= 0) + break; + case 0xBF: /* Ctrl-/ */ TypeAheadString('\0', NULL); SendMessage(hwndFrame, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_SELALL, 0, 0)); return -2; @@ -974,7 +974,7 @@ DirWndProc( // for WM_CREATE, wParam and lParam are ignored // for WM_FSC, wParam is FSC_* and lParam depends on the function (but the cases handled here are limited) // for FS_CHANGEDISPLAY, wParam is one of CD_* values; -// for CD_SORT, LOWORD(lParam) == sort value +// for CD_SORT, LOWORD(lParam) == sort value // for CD_VIEW, LOWORD(lParam) == view bits and HIWORD(lParam) == TRUE means always refresh // for CD_PATH and CD_PATH_FORCE, lParam is the new path; if NULL, use MDI window text @@ -1172,7 +1172,7 @@ ChangeDisplay( dwNewAttribs = (DWORD)GetWindowLongPtr(hwndListParms, GWL_ATTRIBS); SetWindowLongPtr(hwndListParms, GWL_VIEW, dwNewView); - bCreateDTABlock = FALSE; // and szPath is NOT set + bCreateDTABlock = FALSE; // and szPath is NOT set goto CreateLB; } @@ -1307,7 +1307,7 @@ ChangeDisplay( SetWindowLongPtr(hwnd, GWLP_USERDATA, 1); SendMessage(hwndLB, LB_RESETCONTENT, 0, 0L); - // bCreateDTABlock is TRUE and szPath is set + // bCreateDTABlock is TRUE and szPath is set goto CreateNewPath; } @@ -1356,7 +1356,7 @@ ChangeDisplay( // GetMDIWindowText(hwndListParms, szPath, COUNTOF(szPath)); - // bCreateDTABlock == TRUE and szPath just set + // bCreateDTABlock == TRUE and szPath just set CreateLB: @@ -1424,7 +1424,7 @@ ChangeDisplay( CreateNewPath: - if (bCreateDTABlock) { + if (bCreateDTABlock) { // // at this point szPath has the directory to read. this @@ -1432,11 +1432,9 @@ ChangeDisplay( // FS_CHANGEDISPLAY (CD_PATH) directory reset // - CharUpperBuff(szPath, 1); // make sure - - SetWindowLongPtr(hwndListParms, GWL_TYPE, szPath[0] - TEXT('A')); + SetWindowLongPtr(hwndListParms, GWL_TYPE, DRIVEID(szPath)); - SetMDIWindowText(hwndListParms, szPath); + SetMDIWindowText(hwndListParms, szPath); lpStart = CreateDTABlock(hwnd, szPath, @@ -3180,15 +3178,22 @@ UpdateStatus(HWND hwnd) } U_Space(drive); - } qFreeSpace=aDriveInfo[drive].qFreeSpace; qTotalSpace=aDriveInfo[drive].qTotalSpace; + WCHAR szRoot[MAXPATHLEN] = { 0 }; + if (drive < OFFSET_UNC) { + lstrcpy(szRoot, SZ_ACOLON); + DRIVESET(szRoot, drive); + } else { + lstrcpy(szRoot, aDriveInfo[drive].szRoot); + } + SetStatusText(0, SST_RESOURCE|SST_FORMAT, (LPWSTR) MAKEINTRESOURCE(IDS_DRIVEFREE), - L'A' + drive, + szRoot, ShortSizeFormatInternal(szNumBuf1, qFreeSpace), ShortSizeFormatInternal(szNumBuf2, qTotalSpace)); } diff --git a/src/wfdirrd.c b/src/wfdirrd.c index f4868a07..6fb16c63 100644 --- a/src/wfdirrd.c +++ b/src/wfdirrd.c @@ -781,7 +781,15 @@ CreateDTABlockWorker( } } - lstrcpy(szPath+3, lpTemp+1); + // Go back to the root + if (drive < OFFSET_UNC) { + // Easy for drives + lstrcpy(szPath + 3, lpTemp + 1); + } else { + // for UNC one needs to know the UNC root + lstrcpy(szPath, aDriveInfo[drive].szRootBackslash); + lstrcat(szPath, lpTemp + 1); + } SendMessage(hwndDir, FS_CHANGEDISPLAY, @@ -846,10 +854,21 @@ CreateDTABlockWorker( if (!(lpTemp=StrRChr(szPath, NULL, CHAR_BACKSLASH))) goto CDBDiskGone; + // Check if we are at the root of a drive + BOOL bShowDotDot; + if (drive < OFFSET_UNC) + bShowDotDot = (lpTemp - szPath) > 3; + else { + WCHAR szRoot[MAXPATHLEN] = { 0 }; + lstrcpy(szRoot, aDriveInfo[drive].szRootBackslash); + lstrcat(szRoot, szStarDotStar); + bShowDotDot = lstrcmpi(szPath, szRoot); + } + // // Always show .. if this is not the root directory. // - if ((lpTemp - szPath > 3) && (dwAttribs & ATTR_DIR)) { + if (bShowDotDot && (dwAttribs & ATTR_DIR)) { // // Add a DTA to the list. diff --git a/src/wfdlgs.c b/src/wfdlgs.c index ba385699..ec8fe41f 100644 --- a/src/wfdlgs.c +++ b/src/wfdlgs.c @@ -89,20 +89,33 @@ SaveWindows(HWND hwndMain) wsprintf(key, szDirKeyFormat, dir_num--); - // format: - // x_win, y_win, - // x_win, y_win, - // x_icon, y_icon, - // show_window, view, sort, attribs, split, directory - - // NOTE: MDI child windows are in child coordinats; no translation is done. - wsprintf(buf2, TEXT("%ld,%ld,%ld,%ld,%ld,%ld,%u,%lu,%lu,%lu,%d,%s"), - wp.rcNormalPosition.left, wp.rcNormalPosition.top, - wp.rcNormalPosition.right, wp.rcNormalPosition.bottom, - wp.ptMinPosition.x, wp.ptMinPosition.y, - wp.showCmd, view, sort, attribs, - GetSplit(hwnd), - szPath); + INT drive = DRIVEID(szPath); + if (drive < OFFSET_UNC) { + // format: + // x_win, y_win, + // x_win, y_win, + // x_icon, y_icon, + // show_window, view, sort, attribs, split, directory + + // NOTE: MDI child windows are in child coordinats; no translation is done. + wsprintf(buf2, TEXT("%ld,%ld,%ld,%ld,%ld,%ld,%u,%lu,%lu,%lu,%d,%s"), + wp.rcNormalPosition.left, wp.rcNormalPosition.top, + wp.rcNormalPosition.right, wp.rcNormalPosition.bottom, + wp.ptMinPosition.x, wp.ptMinPosition.y, + wp.showCmd, view, sort, attribs, + GetSplit(hwnd), + szPath); + } else { + // For UNC path we need to save the name of the root too + wsprintf(buf2, TEXT("%ld,%ld,%ld,%ld,%ld,%ld,%u,%lu,%lu,%lu,%d,%s\"%s"), + wp.rcNormalPosition.left, wp.rcNormalPosition.top, + wp.rcNormalPosition.right, wp.rcNormalPosition.bottom, + wp.ptMinPosition.x, wp.ptMinPosition.y, + wp.showCmd, view, sort, attribs, + GetSplit(hwnd), + szPath, + aDriveInfo[drive].szRoot); + } // the dir is an ANSI string (?) diff --git a/src/wfdlgs3.c b/src/wfdlgs3.c index d44b6a45..d8d8d3cf 100644 --- a/src/wfdlgs3.c +++ b/src/wfdlgs3.c @@ -582,7 +582,7 @@ FormatDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { nItemIndex++; - wsprintf(szMessage, szBuf, (TCHAR)(CHAR_A+rgiDrive[i]), CHAR_SPACE); + wsprintf(szMessage, szBuf, (TCHAR)(DRIVESET_UC(rgiDrive[i])), CHAR_SPACE); SendDlgItemMessage(hDlg, IDD_DRIVE, CB_INSERTSTRING, count, (LPARAM)szMessage); SendDlgItemMessage(hDlg, IDD_DRIVE, CB_SETITEMDATA, count++, MAKELONG(rgiDrive[i], 0)); @@ -690,7 +690,7 @@ FormatDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) if (bConfirmFormat) { LoadString(hAppInstance, IDS_FORMATCONFIRMTITLE, szTitle, COUNTOF(szTitle)); LoadString(hAppInstance, IDS_FORMATCONFIRM, szBuf, COUNTOF(szBuf)); - wsprintf(szMessage, szBuf, (TCHAR)(CHAR_A+CancelInfo.Info.Format.iFormatDrive)); + wsprintf(szMessage, szBuf, (TCHAR)(DRIVESET_UC(CancelInfo.Info.Format.iFormatDrive))); if (MessageBox(hDlg, szMessage, szTitle, MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON1) != IDYES) break; @@ -886,7 +886,7 @@ FormatDrive( IN PVOID ThreadParameter ) WCHAR wszDrive[3]; WCHAR wszFileSystem[4] = L"FAT"; - wszDrive[0] = (WCHAR)(CancelInfo.Info.Format.iFormatDrive + CHAR_A); + wszDrive[0] = (WCHAR)(DRIVESET_UC(CancelInfo.Info.Format.iFormatDrive)); wszDrive[1] = CHAR_COLON; wszDrive[2] = CHAR_NULL; @@ -917,11 +917,11 @@ CopyDiskette( IN PVOID ThreadParameter ) WCHAR wszSrcDrive[3]; WCHAR wszDestDrive[3]; - wszSrcDrive[0] = (WCHAR)(CancelInfo.Info.Copy.iSourceDrive + CHAR_A); + wszSrcDrive[0] = (WCHAR)(DRIVESET_UC(CancelInfo.Info.Copy.iSourceDrive)); wszSrcDrive[1] = CHAR_COLON; wszSrcDrive[2] = CHAR_NULL; - wszDestDrive[0] = (WCHAR)(CancelInfo.Info.Copy.iDestDrive + CHAR_A); + wszDestDrive[0] = (WCHAR)(DRIVESET_UC(CancelInfo.Info.Copy.iDestDrive)); wszDestDrive[1] = CHAR_COLON; wszDestDrive[2] = CHAR_NULL; diff --git a/src/wfdos.c b/src/wfdos.c index c6dbb901..3bd2b50a 100644 --- a/src/wfdos.c +++ b/src/wfdos.c @@ -22,7 +22,7 @@ GetDiskSpace(DRIVE drive, DRIVESET(szDriveRoot, drive); - if (!GetDiskFreeSpaceEx(szDriveRoot, + if (!GetDiskFreeSpaceEx(drive < OFFSET_UNC ? szDriveRoot : aDriveInfo[drive].szRoot, &qBytesAvailableToCaller, pqTotalSpace, pqFreeSpace)) { @@ -82,14 +82,14 @@ FillVolumeInfo(DRIVE drive, LPTSTR lpszVolName, PDWORD pdwVolumeSerialNumber, TCHAR szDrive[] = SZ_ACOLONSLASH; PDRIVEINFO pDriveInfo = &aDriveInfo[drive]; - DRIVESET(szDrive,drive); + DRIVESET(szDrive, drive); - if (!(GetVolumeInformation(szDrive, - lpszVolName, COUNTOF(pDriveInfo->szVolNameMinusFour)-4, + if (!GetVolumeInformation(drive < OFFSET_UNC ? szDrive : pDriveInfo->szRootBackslash, + lpszVolName, COUNTOF(pDriveInfo->szVolNameMinusFour) - 4, pdwVolumeSerialNumber, pdwMaximumComponentLength, pdwFileSystemFlags, - lpszFileSysName, COUNTOF(pDriveInfo->szFileSysName)))) { + lpszFileSysName, COUNTOF(pDriveInfo->szFileSysName))) { lpszVolName[0] = CHAR_NULL; diff --git a/src/wfdrives.c b/src/wfdrives.c index 2af41c4e..2914613c 100644 --- a/src/wfdrives.c +++ b/src/wfdrives.c @@ -339,7 +339,7 @@ DrawDrive(HDC hdc, INT x, INT y, DRIVEIND driveInd, BOOL bCurrent, BOOL bFocus) if (bFocus) DrawFocusRect(hdc, &rc); - szTemp[0] = (TCHAR)(chFirstDrive + rgiDrive[driveInd]); + szTemp[0] = DRIVESET_LC(rgiDrive[driveInd]); SetBkMode(hdc, TRANSPARENT); rgb = SetTextColor(hdc, rgb); @@ -363,7 +363,7 @@ CheckDrive(HWND hwnd, DRIVE drive, DWORD dwFunc) DWORD err; DRIVEIND driveInd; HCURSOR hCursor; - WCHAR szDrive[] = SZ_ACOLON; + WCHAR szDrive[MAXPATHLEN] = SZ_ACOLON; // Put up the hourglass cursor since this // could take a long time @@ -382,7 +382,13 @@ CheckDrive(HWND hwnd, DRIVE drive, DWORD dwFunc) while ((driveInd < cDrives) && (rgiDrive[driveInd] != drive)) driveInd++; - switch (IsNetDrive(drive)) { + INT iNetDrive; + if (drive < OFFSET_UNC) + iNetDrive = IsNetDrive(drive); + else + iNetDrive = 2; + + switch (iNetDrive) { case 2: @@ -456,6 +462,8 @@ CheckDrive(HWND hwnd, DRIVE drive, DWORD dwFunc) SetCursor(hCursor); ShowCursor(FALSE); + if (drive >= OFFSET_UNC) + lstrcpy(szDrive, aDriveInfo[drive].szRoot); return IsTheDiskReallyThere(hwnd, szDrive, dwFunc, FALSE); } @@ -825,6 +833,7 @@ DrivesWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) InvalidateRect(hWnd, &rc, TRUE); GetDriveRect(nDrive, &rc); InvalidateRect(hWnd, &rc, TRUE); + // UNC How to get there ??? } else if ((wParam >= CHAR_A) && (wParam <= CHAR_Z)) KeyToItem(hWnd, (WORD)wParam); @@ -1116,10 +1125,15 @@ KeyToItem(HWND hWnd, WORD nDriveLetter) { INT nDrive; - if (nDriveLetter > CHAR_Z) - nDriveLetter -= CHAR_a; - else - nDriveLetter -= CHAR_A; + if (ISDIGIT(nDriveLetter)) { + nDriveLetter -= CHAR_ZERO; + nDriveLetter += OFFSET_UNC; + } else { + if (nDriveLetter > CHAR_Z) + nDriveLetter -= CHAR_a; + else + nDriveLetter -= CHAR_A; + } for (nDrive = 0; nDrive < cDrives; nDrive++) { if (rgiDrive[nDrive] == (int)nDriveLetter) { diff --git a/src/wfgoto.cpp b/src/wfgoto.cpp index bb0412ee..b68e81ed 100644 --- a/src/wfgoto.cpp +++ b/src/wfgoto.cpp @@ -603,7 +603,31 @@ SetCurrentPathOfWindow(LPWSTR szPath) { HWND hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); - HWND hwndNew = CreateDirWindow(szPath, TRUE, hwndActive); + HWND hwndNew = nullptr; + if (ISUNCPATH(szPath)) + { + // For UNC path this is the place of opening a new UNC window. + // Use CTRL+W to remove the number-drive mapping and close it + DRIVE freeDriveFound = AddUNCDrive(szPath); + switch (freeDriveFound) + { + case -1: + // UNC Loop found. Throw your favourite messagebox here + break; + + case 0: + // Out of free UNC Slots. Throw your favourite messagebox here + break; + + // drive slot found > 0 + default: + hwndNew = CreateDirWindow(szPath, FALSE, hwndActive); + if (hwndNew) + RefreshWindow(hwndNew, TRUE, TRUE); + } + } + else + hwndNew = CreateDirWindow(szPath, TRUE, hwndActive); HWND hwndTree = HasTreeWindow(hwndNew); if (hwndTree) diff --git a/src/wfinfo.c b/src/wfinfo.c index e909f3d8..6c0732ae 100644 --- a/src/wfinfo.c +++ b/src/wfinfo.c @@ -89,7 +89,15 @@ U_HEAD(Type) DRIVESET(szDrive, drive); IF_READ(Type) - uType = GetDriveType(szDrive); + if (drive < OFFSET_UNC) + uType = GetDriveType(szDrive); + else + { + if (pDriveInfo->szRootBackslash[0]) + uType = GetDriveType(pDriveInfo->szRootBackslash); + else + uType = DRIVE_UNKNOWN; + } ENTER_MODIFY(Type) @@ -269,7 +277,20 @@ U_HEAD(NetCon) pDriveInfo->dwConnectInfoMax = dwSize; - dwRetVal = WNetGetConnection2(szDrive, lpConnectInfo, &dwSize); + if (drive < OFFSET_UNC) + dwRetVal = WNetGetConnection2(szDrive, lpConnectInfo, &dwSize); + else + { + // Mimic WNetGetConnection2() + lpConnectInfo->lpRemoteName = LocalAlloc(LPTR, lstrlen(aDriveInfo[drive].szRoot) * 2 + 2); + lstrcpy(lpConnectInfo->lpRemoteName, aDriveInfo[drive].szRoot); + + #define NetWorkProvider L"Microsoft Windows Network" + lpConnectInfo->lpProvider = LocalAlloc(LPTR, sizeof(NetWorkProvider) + 2); + lstrcpy(lpConnectInfo->lpProvider, NetWorkProvider); + + dwRetVal = ERROR_SUCCESS; + } if (ERROR_MORE_DATA == dwRetVal) { diff --git a/src/wfinit.c b/src/wfinit.c index b43f8b86..aae1b993 100644 --- a/src/wfinit.c +++ b/src/wfinit.c @@ -736,7 +736,20 @@ GetSavedWindow( count++; } - lstrcpy(pwin->szDir, szBuf); // this is the directory + // Search for an optional name of the root, which seperated by " from the directory + // e.g. + // dir1==....,\\unc\path1\*.*"\\unc\path1\aurea\prima + // It is " because is must be a character, which is not allowed in pathnames + LPTSTR szDir = szBuf; + while (*szBuf && *szBuf != CHAR_DQUOTE) + szBuf++; + if (*szBuf) { + *szBuf = CHAR_NULL; + lstrcpy(pwin->szRoot, ++szBuf); // name of the root + } else { + pwin->szRoot[0] = CHAR_NULL; + } + lstrcpy(pwin->szDir, szDir); // this is the directory } @@ -746,13 +759,14 @@ CheckDirExists( { BOOL bRet = FALSE; - if (IsNetDrive(DRIVEID(szDir)) == 2) { + DRIVE drive = DRIVEID(szDir); + if (IsNetDrive(drive) == 2 || drive >= OFFSET_UNC) { - CheckDrive(hwndFrame, DRIVEID(szDir), FUNC_SETDRIVE); + CheckDrive(hwndFrame, drive, FUNC_SETDRIVE); return TRUE; } - if (IsValidDisk(DRIVEID(szDir))) + if (IsValidDisk(drive)) bRet = SetCurrentDirectory(szDir); return bRet; @@ -790,22 +804,31 @@ CreateSavedWindows() GetSavedWindow(buf, &win); - // - // clean off some junk so we - // can do this test - // lstrcpy(szDir, win.szDir); + + // clean off some junk so we can do this test StripFilespec(szDir); StripBackslash(szDir); + if (win.szRoot[0]) + // UNC Drive + AddUNCDrive(win.szRoot); + else + // In case of broken .ini file and UNC + if (ISUNCPATH(szDir)) + AddUNCDrive(szDir); + if (!CheckDirExists(szDir)) continue; + AddBackslash(szDir); + lstrcat(szDir, szStarDotStar); + dwNewView = win.dwView; dwNewSort = win.dwSort; dwNewAttribs = win.dwAttribs; - hwnd = CreateTreeWindow(win.szDir, + hwnd = CreateTreeWindow(szDir, win.rc.left, win.rc.top, win.rc.right - win.rc.left, @@ -1051,7 +1074,7 @@ JAPANEND // SetErrorMode(1); - for (i=0; i<26;i++) { + for (i = 0; i < MAX_DRIVES; i++) { I_Space(i); } @@ -1096,8 +1119,6 @@ JAPANEND hicoTreeDir = LoadIcon(hAppInstance, (LPTSTR) MAKEINTRESOURCE(TREEDIRICON)); hicoDir = LoadIcon(hAppInstance, (LPTSTR) MAKEINTRESOURCE(DIRICON)); - chFirstDrive = CHAR_a; - // now build the parameters based on the font we will be using hdcScreen = GetDC(NULL); diff --git a/src/wftree.c b/src/wftree.c index 2367fb9d..a8c3ca17 100644 --- a/src/wftree.c +++ b/src/wftree.c @@ -530,8 +530,8 @@ TreeWndProc( case WM_CREATE: { -#define lpcs ((LPCREATESTRUCT)lParam) -#define lpmdics ((LPMDICREATESTRUCT)(lpcs->lpCreateParams)) + LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; + LPMDICREATESTRUCT lpmdics = (LPMDICREATESTRUCT)(lpcs->lpCreateParams); INT dxSplit; DRIVE drive; @@ -590,8 +590,6 @@ TreeWndProc( SetMDIWindowText(hwnd, szPath); break; -#undef lpcs -#undef lpmdics } case WM_CLOSE: diff --git a/src/wfutil.c b/src/wfutil.c index de895900..29854d5e 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -14,49 +14,49 @@ #include #include -LPTSTR CurDirCache[26]; +LPTSTR CurDirCache[MAX_DRIVES]; #define MAXHISTORY 32 DWORD historyCur = 0; typedef struct HistoryDir { - HWND hwnd; - TCHAR szDir[MAXPATHLEN]; + HWND hwnd; + TCHAR szDir[MAXPATHLEN]; } HistoryDir; HistoryDir rghistoryDir[MAXHISTORY]; VOID SaveHistoryDir(HWND hwnd, LPWSTR szDir) { - if (rghistoryDir[historyCur].hwnd == hwnd && lstrcmpi(rghistoryDir[historyCur].szDir, szDir) == 0) - return; + if (rghistoryDir[historyCur].hwnd == hwnd && lstrcmpi(rghistoryDir[historyCur].szDir, szDir) == 0) + return; - historyCur = (historyCur + 1) % MAXHISTORY; + historyCur = (historyCur + 1) % MAXHISTORY; - rghistoryDir[historyCur].hwnd = hwnd; - lstrcpy(rghistoryDir[historyCur].szDir, szDir); + rghistoryDir[historyCur].hwnd = hwnd; + lstrcpy(rghistoryDir[historyCur].szDir, szDir); - // always leave one NULL entry after current - DWORD historyT = (historyCur + 1) % MAXHISTORY; - rghistoryDir[historyT].hwnd = NULL; - rghistoryDir[historyT].szDir[0] = '\0'; + // always leave one NULL entry after current + DWORD historyT = (historyCur + 1) % MAXHISTORY; + rghistoryDir[historyT].hwnd = NULL; + rghistoryDir[historyT].szDir[0] = '\0'; } BOOL GetPrevHistoryDir(BOOL forward, HWND *phwnd, LPWSTR szDir) { - DWORD historyNext = (historyCur + 1) % MAXHISTORY; - DWORD historyPrev = (historyCur == 0 ? MAXHISTORY : historyCur )- 1; - DWORD historyT = forward ? historyNext : historyPrev; - - if (rghistoryDir[historyT].hwnd == NULL) - return FALSE; - - historyCur = historyT; - - *phwnd = rghistoryDir[historyCur].hwnd; - lstrcpy(szDir, rghistoryDir[historyCur].szDir); - return TRUE; + DWORD historyNext = (historyCur + 1) % MAXHISTORY; + DWORD historyPrev = (historyCur == 0 ? MAXHISTORY : historyCur )- 1; + DWORD historyT = forward ? historyNext : historyPrev; + + if (rghistoryDir[historyT].hwnd == NULL) + return FALSE; + + historyCur = historyT; + + *phwnd = rghistoryDir[historyCur].hwnd; + lstrcpy(szDir, rghistoryDir[historyCur].szDir); + return TRUE; } LPWSTR @@ -209,7 +209,7 @@ GetSelectedDirectory(DRIVE drive, LPTSTR pszDir) goto hwndfound; } if (!GetSavedDirectory(drive - 1, pszDir)) { - GetDriveDirectory(drive, pszDir); + GetDriveDirectory(drive, pszDir); } return; } else @@ -224,11 +224,13 @@ GetSelectedDirectory(DRIVE drive, LPTSTR pszDir) BOOL GetDriveDirectory(INT iDrive, LPTSTR pszDir) { - TCHAR drvstr[4]; DWORD ret; + WCHAR drvstr[MAXPATHLEN]; - pszDir[0] = '\0'; - + if (iDrive - 1 < OFFSET_UNC) + { + pszDir[0] = '\0'; + if(iDrive!=0) { drvstr[0] = ('A') - 1 + iDrive; @@ -241,16 +243,18 @@ BOOL GetDriveDirectory(INT iDrive, LPTSTR pszDir) drvstr[0] = ('.'); drvstr[1] = ('\0'); } + } + else + { + lstrcpy(drvstr, aDriveInfo[iDrive - 1].szRoot); + } - if (GetFileAttributes(drvstr) == INVALID_FILE_ATTRIBUTES) - return FALSE; - -// if (!CheckDirExists(drvstr)) -// return FALSE; + if (GetFileAttributes(drvstr) == INVALID_FILE_ATTRIBUTES) + return FALSE; ret = GetFullPathName( drvstr, MAXPATHLEN, pszDir, NULL); - return ret != 0; + return ret != 0; } @@ -259,42 +263,42 @@ BOOL GetDriveDirectory(INT iDrive, LPTSTR pszDir) VOID GetAllDirectories(LPTSTR rgszDirs[]) { - HWND mpdrivehwnd[MAX_DRIVES]; + HWND mpdrivehwnd[MAX_DRIVES]; HWND hwnd; DRIVE driveT; - for (driveT = 0; driveT < MAX_DRIVES; driveT++) - { - rgszDirs[driveT] = NULL; - mpdrivehwnd[driveT] = NULL; - } - + for (driveT = 0; driveT < MAX_DRIVES; driveT++) + { + rgszDirs[driveT] = NULL; + mpdrivehwnd[driveT] = NULL; + } + for (hwnd = GetWindow(hwndMDIClient,GW_CHILD); hwnd; hwnd = GetWindow(hwnd,GW_HWNDNEXT)) { - driveT = (DRIVE)SendMessage(hwnd,FS_GETDRIVE,0,0L) - CHAR_A; - if (mpdrivehwnd[driveT] == NULL) - mpdrivehwnd[driveT] = hwnd; - } - - for (driveT = 0; driveT < MAX_DRIVES; driveT++) - { - TCHAR szDir[MAXPATHLEN]; - - if (mpdrivehwnd[driveT] != NULL) - { - SendMessage(mpdrivehwnd[driveT],FS_GETDIRECTORY,MAXPATHLEN,(LPARAM)szDir); - - StripBackslash(szDir); - } - else if (!GetSavedDirectory(driveT, szDir)) - szDir[0] = '\0'; - - if (szDir[0] != '\0') - { - rgszDirs[driveT] = (LPTSTR) LocalAlloc(LPTR, ByteCountOf(lstrlen(szDir)+1)); - lstrcpy(rgszDirs[driveT], szDir); - } - } + driveT = (DRIVE)SendMessage(hwnd,FS_GETDRIVE,0,0L) - CHAR_A; + if (mpdrivehwnd[driveT] == NULL) + mpdrivehwnd[driveT] = hwnd; + } + + for (driveT = 0; driveT < MAX_DRIVES; driveT++) + { + TCHAR szDir[MAXPATHLEN]; + + if (mpdrivehwnd[driveT] != NULL) + { + SendMessage(mpdrivehwnd[driveT],FS_GETDIRECTORY,MAXPATHLEN,(LPARAM)szDir); + + StripBackslash(szDir); + } + else if (!GetSavedDirectory(driveT, szDir)) + szDir[0] = '\0'; + + if (szDir[0] != '\0') + { + rgszDirs[driveT] = (LPTSTR) LocalAlloc(LPTR, ByteCountOf(lstrlen(szDir)+1)); + lstrcpy(rgszDirs[driveT], szDir); + } + } } @@ -771,8 +775,6 @@ SetMDIWindowText( SaveHistoryDir(hwnd, szTitle); } -#define ISDIGIT(c) ((c) >= TEXT('0') && (c) <= TEXT('9')) - INT atoiW(LPTSTR sz) { @@ -1617,3 +1619,79 @@ BOOL TypeAheadString(WCHAR ch, LPWSTR szT) return ich != 0; } + +// Search the list of slots if path would be parent of already existing drive == circularity +BOOL FindUNCLoop(LPCTSTR path) +{ + for (DWORD dwDriveIndex = OFFSET_UNC; dwDriveIndex < MAX_DRIVES; ++dwDriveIndex) { + if (aDriveInfo[dwDriveIndex].szRoot[0] && StrStrIW(aDriveInfo[dwDriveIndex].szRoot, path)) + return TRUE; + } + return FALSE; +} + +DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot) +{ + // Search the list of slots if drive is already there + for (DWORD dwDriveIndex = OFFSET_UNC; dwDriveIndex < MAX_DRIVES; ++dwDriveIndex) { + // Found existing slot + if (aDriveInfo[dwDriveIndex].szRoot[0] && StrStrIW(path, aDriveInfo[dwDriveIndex].szRoot)) + // Added an UNC drive which already existed + return dwDriveIndex; + + // If we come across an empty one, remember the first one + if (!aDriveInfo[dwDriveIndex].szRoot[0] && !(*pdwFreeDriveSlot)) + *pdwFreeDriveSlot = dwDriveIndex; + } + return 0; +} + +// Returns drive-id if possible. If not returns 0 +// Possible failure reasons: Exceeded number of free numbered drives or UNC cirularity +DRIVE AddUNCDrive(LPTSTR path) +{ + StripBackslash(path); + if (FindUNCLoop(path)) + return -1; + + DWORD dwFreeDriveSlot = 0; + DRIVE drive = FindUNCDrive(path, &dwFreeDriveSlot); + if (!drive && dwFreeDriveSlot) { + // Havent't found an existing slot, so add new to first free found + lstrcpy(aDriveInfo[dwFreeDriveSlot].szRoot, path); + lstrcpy(aDriveInfo[dwFreeDriveSlot].szRootBackslash, path); + AddBackslash(aDriveInfo[dwFreeDriveSlot].szRootBackslash); + drive = dwFreeDriveSlot; + } + + return drive; +} + +DRIVE RemoveUNCDrive(LPCTSTR path) +{ + DWORD dwFreeDriveSlot = 0; + DRIVE drive = FindUNCDrive(path, &dwFreeDriveSlot); + if (drive) { + // Found an empty slot so mark it free + aDriveInfo[drive].szRoot[0] = '\0'; + aDriveInfo[drive].szRootBackslash[0] = '\0'; + I_Space(drive); + } + + return dwFreeDriveSlot; +} + +DRIVE DRIVEID(LPCTSTR path) +{ + DRIVE drive = toupper(path[0]); + if (drive >= CHAR_A && drive <= CHAR_Z) + // regular drive + return drive - CHAR_A; + + DWORD dwFreeDriveSlot = 0; + drive = FindUNCDrive(path, &dwFreeDriveSlot); + if (drive) + return drive; + + return MAX_DRIVES; +} diff --git a/src/winfile.h b/src/winfile.h index b9b60d47..40e004bd 100644 --- a/src/winfile.h +++ b/src/winfile.h @@ -104,7 +104,9 @@ INT atoiW(LPWSTR sz); #define MAXMESSAGELEN (MAXPATHLEN * 2 + MAXSUGGESTLEN) #define MAX_WINDOWS 27 -#define MAX_DRIVES 26 +#define MAX_UNC 10 +#define OFFSET_UNC 'Z' - 'A' + 1 +#define MAX_DRIVES OFFSET_UNC + MAX_UNC // struct for volume info @@ -184,6 +186,7 @@ INT atoiW(LPWSTR sz); #define CHAR_A TEXT('A') #define CHAR_a TEXT('a') #define CHAR_Z TEXT('Z') +#define CHAR_z TEXT('z') // Default char for untranslatable unicode // MUST NOT BE an acceptable char for file systems!! @@ -202,13 +205,14 @@ INT atoiW(LPWSTR sz); #define DwordAlign(cb) (((cb) + 3) & ~3) #define ISDOTDIR(x) (x[0]==CHAR_DOT && (!x[1] || (x[1] == CHAR_DOT && !x[2]))) #define ISUNCPATH(x) (CHAR_BACKSLASH == x[0] && CHAR_BACKSLASH == x[1]) -#define DRIVESET(str, drive) (str[0] = CHAR_A + (drive)) +#define DRIVESET_LC(drive) ((drive < OFFSET_UNC ? CHAR_a : CHAR_Z - CHAR_A - 3) + drive) +#define DRIVESET_UC(drive) ((drive < OFFSET_UNC ? CHAR_A : CHAR_Z - CHAR_A - 3) + drive) +#define DRIVESET(str, drive) (str[0] = DRIVESET_UC(drive)) +#define ISDIGIT(c) ((c) >= TEXT('0') && (c) <= TEXT('9')) #define COUNTOF(x) (sizeof(x)/sizeof(*x)) #define ByteCountOf(x) ((x)*sizeof(TCHAR)) #define abs(x) (((x) < 0) ? -(x) : (x)) -#define DRIVEID(path) ((path[0] - CHAR_A)&31) - #define IsDocument(lpszPath) IsBucketFile(lpszPath, ppDocBucket) #define IsProgramFile(lpszPath) IsBucketFile(lpszPath, ppProgBucket) #define IsProgramIconFile(lpszPath) IsBucketFile(lpszPath, ppProgIconBucket) @@ -307,6 +311,7 @@ typedef struct { // *2 since may have huge filter // WCHAR szDir[2*MAXPATHLEN]; + WCHAR szRoot[MAXPATHLEN]; // // Next block of fields must be together (11 DWORDS) @@ -430,6 +435,12 @@ BOOL TypeAheadString(WCHAR ch, LPWSTR szT); VOID SaveHistoryDir(HWND hwnd, LPWSTR szDir); BOOL GetPrevHistoryDir(BOOL forward, HWND *phwnd, LPWSTR szDir); +DRIVE DRIVEID(LPCTSTR path); +DRIVE AddUNCDrive(LPTSTR path); +DRIVE RemoveUNCDrive(LPCTSTR path); +DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot); +BOOL FindUNCLoop(LPCTSTR path); + // WFDIR.C VOID UpdateStatus(HWND hWnd); @@ -939,6 +950,9 @@ typedef struct _DRIVE_INFO { STATUSNAME(Space); LARGE_INTEGER qFreeSpace; LARGE_INTEGER qTotalSpace; + + TCHAR szRoot[MAXPATHLEN]; + TCHAR szRootBackslash[MAXPATHLEN]; } DRIVEINFO, *PDRIVEINFO; #define SC_SPLIT 100 @@ -1127,8 +1141,9 @@ Extern DWORD gdwMachineId EQ( MACHINEID_MICROSOFT ); #define rgiDrive rgiDriveReal[iUpdateReal] Extern INT iUpdateReal EQ( 0 ); -Extern DRIVE rgiDriveReal[2][26]; -Extern DRIVEINFO aDriveInfo[26]; + +Extern DRIVE rgiDriveReal[2][MAX_DRIVES]; +Extern DRIVEINFO aDriveInfo[MAX_DRIVES]; Extern UINT uMenuID; Extern HMENU hMenu; @@ -1173,8 +1188,6 @@ Extern BOOL bConnectable EQ( FALSE ); Extern INT iShowSourceBitmaps EQ( 1 ); Extern BOOL bFSCTimerSet EQ( FALSE ); -Extern TCHAR chFirstDrive; // 'A' or 'a' - Extern TCHAR szExtensions[] EQ( TEXT("Extensions") ); Extern TCHAR szFrameClass[] EQ( TEXT("WFS_Frame") ); Extern TCHAR szTreeClass[] EQ( TEXT("WFS_Tree") ); From 20db1364b022033c63f8b5db96071918379204b2 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sun, 27 Aug 2023 08:53:19 +0200 Subject: [PATCH 02/14] FastMove was not working on UNC path --- src/wfcopy.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wfcopy.c b/src/wfcopy.c index 407ab088..7ba9090c 100644 --- a/src/wfcopy.c +++ b/src/wfcopy.c @@ -2714,9 +2714,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter) #endif #ifdef FASTMOVE - if ((CHAR_COLON == pcr->sz[1]) && - (CHAR_COLON == szDest[1]) && - (DRIVEID(pcr->sz) == DRIVEID(szDest))) { + if (DRIVEID(pcr->sz) == DRIVEID(szDest)) { // // Warning: This will not work on winball drives! From 718d19328c3add096ac5fb04ffcc60df0637a7b8 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Thu, 14 Sep 2023 10:29:20 +0200 Subject: [PATCH 03/14] QualifyPath() now treats 'digit drives' ( e.g. 1:\ ) long file name capable drives, because they are UNC drives --- src/wfcopy.c | 6 +++--- src/winfile.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wfcopy.c b/src/wfcopy.c index 7ba9090c..958b6eb1 100644 --- a/src/wfcopy.c +++ b/src/wfcopy.c @@ -265,8 +265,6 @@ JAPANBEGIN // Allocate enough space for 8.3 conversion to DBCS here (each // part done individually, so 8 chars is enough). // - LPSTR pOrigA; - CHAR szOrigA[8*2]; JAPANEND // @@ -357,7 +355,7 @@ JAPANEND DRIVESET(szDrive,drive); - flfn = IsLFNDrive(szDrive); + flfn = IsLFNDrive(szDrive) || ISDIGIT_DRIVE(szDrive); // // on FAT _AND_ lfn devices, replace any illegal chars with underscores @@ -475,6 +473,8 @@ JAPANEND } else { + LPSTR pOrigA; + CHAR szOrigA[11 * 2]; if (bJAPAN) { if (!WideCharToMultiByte(CP_ACP, 0, diff --git a/src/winfile.h b/src/winfile.h index 40e004bd..af186505 100644 --- a/src/winfile.h +++ b/src/winfile.h @@ -209,6 +209,7 @@ INT atoiW(LPWSTR sz); #define DRIVESET_UC(drive) ((drive < OFFSET_UNC ? CHAR_A : CHAR_Z - CHAR_A - 3) + drive) #define DRIVESET(str, drive) (str[0] = DRIVESET_UC(drive)) #define ISDIGIT(c) ((c) >= TEXT('0') && (c) <= TEXT('9')) +#define ISDIGIT_DRIVE(str) (CHAR_COLON == str[1] && ISDIGIT(str[0])) #define COUNTOF(x) (sizeof(x)/sizeof(*x)) #define ByteCountOf(x) ((x)*sizeof(TCHAR)) #define abs(x) (((x) < 0) ? -(x) : (x)) From 9a84d0a12b4a37aa0b33e98cf46bb9fd2295b5f3 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sun, 17 Sep 2023 12:37:52 +0200 Subject: [PATCH 04/14] Repair unreadable identation --- src/wfcomman.c | 79 +++++++++++++++++++++++--------------------------- src/wfutil.c | 54 +++++++++++++++++----------------- 2 files changed, 64 insertions(+), 69 deletions(-) diff --git a/src/wfcomman.c b/src/wfcomman.c index cdcf2066..2e01400e 100644 --- a/src/wfcomman.c +++ b/src/wfcomman.c @@ -510,10 +510,10 @@ CreateDirWindow( INT dxSplit; if (hwndActive == hwndSearch) { - bReplaceOpen = FALSE; - dxSplit = -1; + bReplaceOpen = FALSE; + dxSplit = -1; } else { - dxSplit = GetSplit(hwndActive); + dxSplit = GetSplit(hwndActive); } // @@ -531,46 +531,41 @@ CreateDirWindow( // Are we replacing the contents of the currently active child? // if (bReplaceOpen) { - DRIVE drive = DRIVEID(szPath); - for (INT i = 0; i < cDrives; i++) - { - if (drive == rgiDrive[i]) - { - // if not already selected, do so now - if (i != SendMessage(hwndDriveList, CB_GETCURSEL, i, 0L)) - { - SelectToolbarDrive(i); - } - break; - } - } + DRIVE drive = DRIVEID(szPath); + for (INT i = 0; i < cDrives; i++) { + if (drive == rgiDrive[i]) { + // if not already selected, do so now + if (i != SendMessage(hwndDriveList, CB_GETCURSEL, i, 0L)) { + SelectToolbarDrive(i); + } + break; + } + } - if (hwndT = HasDirWindow(hwndActive)) - { - WCHAR szFileSpec[MAXPATHLEN]; + if (hwndT = HasDirWindow(hwndActive)) { + WCHAR szFileSpec[MAXPATHLEN]; - AddBackslash(szPath); // default to all files - SendMessage(hwndT, FS_GETFILESPEC, COUNTOF(szFileSpec), (LPARAM)szFileSpec); - lstrcat(szPath, szFileSpec); - SendMessage(hwndT, FS_CHANGEDISPLAY, CD_PATH, (LPARAM)szPath); - StripFilespec(szPath); - } + AddBackslash(szPath); // default to all files + SendMessage(hwndT, FS_GETFILESPEC, COUNTOF(szFileSpec), (LPARAM)szFileSpec); + lstrcat(szPath, szFileSpec); + SendMessage(hwndT, FS_CHANGEDISPLAY, CD_PATH, (LPARAM)szPath); + StripFilespec(szPath); + } - // - // update the tree if necessary - // - ; - if (hwndT = HasTreeWindow(hwndActive)) - { - SendMessage(hwndT, TC_SETDRIVE, 0, (LPARAM)(szPath)); - } + // + // update the tree if necessary + // + ; + if (hwndT = HasTreeWindow(hwndActive)) { + SendMessage(hwndT, TC_SETDRIVE, 0, (LPARAM)(szPath)); + } - // - // Update the status in case we are "reading" - // - UpdateStatus(hwndActive); + // + // Update the status in case we are "reading" + // + UpdateStatus(hwndActive); - return hwndActive; + return hwndActive; } AddBackslash(szPath); // default to all files @@ -583,10 +578,10 @@ CreateDirWindow( // call TC_SETDRIVE like use of CreateTreeWindow in NewTree() if (hwndActive && (hwndT = HasTreeWindow(hwndActive))) - SendMessage(hwndT, - TC_SETDRIVE, - MAKELONG(MAKEWORD(FALSE, 0), TRUE), - 0L); + SendMessage(hwndT, + TC_SETDRIVE, + MAKELONG(MAKEWORD(FALSE, 0), TRUE), + 0L); return hwndActive; } diff --git a/src/wfutil.c b/src/wfutil.c index 29854d5e..f9c0712c 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -224,37 +224,37 @@ GetSelectedDirectory(DRIVE drive, LPTSTR pszDir) BOOL GetDriveDirectory(INT iDrive, LPTSTR pszDir) { - DWORD ret; - WCHAR drvstr[MAXPATHLEN]; + DWORD ret; + WCHAR drvstr[MAXPATHLEN]; - if (iDrive - 1 < OFFSET_UNC) - { - pszDir[0] = '\0'; - - if(iDrive!=0) - { - drvstr[0] = ('A') - 1 + iDrive; - drvstr[1] = (':'); - drvstr[2] = ('.'); - drvstr[3] = ('\0'); - } - else - { - drvstr[0] = ('.'); - drvstr[1] = ('\0'); - } - } - else - { - lstrcpy(drvstr, aDriveInfo[iDrive - 1].szRoot); - } + if (iDrive - 1 < OFFSET_UNC) + { + pszDir[0] = '\0'; + + if (iDrive != 0) + { + drvstr[0] = ('A') - 1 + iDrive; + drvstr[1] = (':'); + drvstr[2] = ('.'); + drvstr[3] = ('\0'); + } + else + { + drvstr[0] = ('.'); + drvstr[1] = ('\0'); + } + } + else + { + lstrcpy(drvstr, aDriveInfo[iDrive - 1].szRoot); + } - if (GetFileAttributes(drvstr) == INVALID_FILE_ATTRIBUTES) - return FALSE; + if (GetFileAttributes(drvstr) == INVALID_FILE_ATTRIBUTES) + return FALSE; - ret = GetFullPathName( drvstr, MAXPATHLEN, pszDir, NULL); + ret = GetFullPathName(drvstr, MAXPATHLEN, pszDir, NULL); - return ret != 0; + return ret != 0; } From 6ec370ab0103d93519ee26909a5044efa9d9d912 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Tue, 19 Sep 2023 07:44:07 +0200 Subject: [PATCH 05/14] Immediatley give up on not existing UNC Drives. They will not reconnect at some time --- src/wfinit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wfinit.c b/src/wfinit.c index aae1b993..6c6c7953 100644 --- a/src/wfinit.c +++ b/src/wfinit.c @@ -760,6 +760,11 @@ CheckDirExists( BOOL bRet = FALSE; DRIVE drive = DRIVEID(szDir); + + // Immediatley give up on not existing UNC Drives. They will not reconnect at some time + if (drive >= OFFSET_UNC && INVALID_FILE_ATTRIBUTES == GetFileAttributes(szDir)) + return FALSE; + if (IsNetDrive(drive) == 2 || drive >= OFFSET_UNC) { CheckDrive(hwndFrame, drive, FUNC_SETDRIVE); From 897e6f043d439aac956c2560afaddcbef11a65bd Mon Sep 17 00:00:00 2001 From: schinagl Date: Tue, 26 Sep 2023 21:48:06 +0200 Subject: [PATCH 06/14] Revert indentation of accidently formatted files --- src/lang/res_ja-JP.rc | 54 ++++++------ src/treectl.c | 190 +++++++++++++++++++++--------------------- src/wfcomman.c | 8 +- src/wfdir.c | 24 +++--- src/wfgoto.cpp | 66 +++++++-------- src/wfutil.c | 110 ++++++++++++------------ 6 files changed, 226 insertions(+), 226 deletions(-) diff --git a/src/lang/res_ja-JP.rc b/src/lang/res_ja-JP.rc index c1970ea2..49fa434a 100644 --- a/src/lang/res_ja-JP.rc +++ b/src/lang/res_ja-JP.rc @@ -14,14 +14,14 @@ BEGIN POPUP "ファイル(&F)" BEGIN MENUITEM "開く(&O)\tEnter", IDM_OPEN - MENUITEM "編集\tF12", IDM_EDIT + MENUITEM "編集\tF12", IDM_EDIT MENUITEM "移動(&M)...\tF7", IDM_MOVE MENUITEM "コピー(&C)...\tF8", IDM_COPY - MENUITEM "シンボリックリンク(&Y)...\tF11", IDM_SYMLINK - MENUITEM "ハードリンク(&K)...\tShift+F11", IDM_HARDLINK + MENUITEM "シンボリックリンク(&Y)...\tF11", IDM_SYMLINK + MENUITEM "ハードリンク(&K)...\tShift+F11", IDM_HARDLINK MENUITEM "クリップボードにコピー(&B)...\tCtrl+C", IDM_COPYTOCLIPBOARD - MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD - MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE + MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD + MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE MENUITEM "削除(&D)...\tDel", IDM_DELETE MENUITEM "名前の変更(&N)...", IDM_RENAME MENUITEM "プロパティ(&T)...\tAlt+Enter",IDM_ATTRIBS @@ -43,7 +43,7 @@ BEGIN MENUITEM "&PowerShell を起動...\tCtrl+P", IDM_STARTPOWERSHELL MENUITEM "&Explorer を起動...\tCtrl+E", IDM_STARTEXPLORER END - MENUITEM "別のディレクトリへ移動(&G)...\tCtrl+G", IDM_GOTODIR + MENUITEM "別のディレクトリへ移動(&G)...\tCtrl+G", IDM_GOTODIR MENUITEM SEPARATOR MENUITEM "終了(&X)", IDM_EXIT END @@ -93,8 +93,8 @@ BEGIN MENUITEM "追加の設定(&P)", IDM_PREF MENUITEM SEPARATOR MENUITEM "ツール バー(&T)", IDM_TOOLBAR - MENUITEM "ドライブバー(&D)", IDM_DRIVEBAR - MENUITEM "ステータスバー(&S)", IDM_STATUSBAR + MENUITEM "ドライブ バー(&D)", IDM_DRIVEBAR + MENUITEM "ステータス バー(&S)", IDM_STATUSBAR MENUITEM SEPARATOR MENUITEM "プログラムの起動時に最小化(&M)", IDM_MINONRUN MENUITEM "起動時に移動先インデックスを作成(&G)", IDM_INDEXONLAUNCH @@ -132,28 +132,28 @@ END CTXMENU MENU BEGIN - POPUP "Dummy Popup" - BEGIN - MENUITEM "新しいウィンドウ(&N)\tCtrl+Shift Enter", IDM_NEWWINDOW + POPUP "Dummy Popup" + BEGIN + MENUITEM "新しいウィンドウ(&N)\tCtrl+Shift Enter", IDM_NEWWINDOW MENUITEM "開く(&O)\tEnter", IDM_OPEN - MENUITEM "編集\tF12", IDM_EDIT + MENUITEM "編集\tF12", IDM_EDIT MENUITEM "移動(&M)...\tF7", IDM_MOVE MENUITEM "コピー(&C)...\tF8", IDM_COPY MENUITEM "シンボリックリンク(&Y)...\tF11", IDM_SYMLINK MENUITEM "ハードリンク(&K)...\tShift+F11", IDM_HARDLINK - MENUITEM "クリップボードにコピー(&B)\tCtrl+C", IDM_COPYTOCLIPBOARD - MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD - MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE - MENUITEM "削除(&D)...\tDel", IDM_DELETE + MENUITEM "クリップボードにコピー(&B)\tCtrl+C", IDM_COPYTOCLIPBOARD + MENUITEM "クリップボードに切り取り\tCtrl+X", IDM_CUTTOCLIPBOARD + MENUITEM "貼り付け(&P)\tCtrl+V", IDM_PASTE + MENUITEM "削除(&D)...\tDel", IDM_DELETE MENUITEM "名前の変更(&N)...\tF2", IDM_RENAME MENUITEM "プロパティ(&T)...\tAlt+Enter",IDM_ATTRIBS MENUITEM "実行(&R)...", IDM_RUN MENUITEM "Bash を起動...", IDM_STARTBASHSHELL - MENUITEM "コマンド プロンプトを起動(&L)...", IDM_STARTCMDSHELL - MENUITEM "PowerShell を起動(&W)...", IDM_STARTPOWERSHELL + MENUITEM "コマンド プロンプトを起動(&L)...", IDM_STARTCMDSHELL + MENUITEM "PowerShell を起動(&W)...", IDM_STARTPOWERSHELL MENUITEM "Explorer を起動(&X)...", IDM_STARTEXPLORER - MENUITEM "別のディレクトリへ移動(&G)...", IDM_GOTODIR - END + MENUITEM "別のディレクトリへ移動(&G)...", IDM_GOTODIR + END END @@ -200,7 +200,7 @@ BEGIN IDS_LABELDISKERR "ファイル マネージャーはフロッピー ディスクにボリューム ラベルを付けられません。\n\nフロッピー ディスクが書き込み禁止になっていない事、ネットワーク ドライブではない事を確認して、正しい名前を入力して下さい。\n名前には次の文字を含めることはできません:\n[空白] * ? / \\ | . , ; : + = [ ] ( ) & ^ < > "" " - IDS_SEARCHNOMATCHES "一致するファイルが見つかりませんでした。" + IDS_SEARCHNOMATCHES "一致するファイルが見つかりませんでした。" IDS_SEARCHREFRESH "このドライブの内容が変更されました。検索を再度実行しますか?" IDS_LABELACCESSDENIED "この操作をハード ディスク上で実行するには、このワークステーションに管理者としてログインする必要があります。" @@ -258,10 +258,10 @@ BEGIN IDS_SYMLINK, "シンボリックリンク" /* 32 */ IDS_HARDLINK, "ハードリンク" /* 32 */ - IDS_KK_COPYFROMSTR, "コピー元(&F):" - IDS_KK_COPYTOSTR, "コピー先(&T):" - IDS_KK_RENAMEFROMSTR, "元の名前(&F):" - IDS_KK_RENAMETOSTR, "新しい名前(&T):" + IDS_KK_COPYFROMSTR, "コピー元(&F):" + IDS_KK_COPYTOSTR, "コピー先(&T):" + IDS_KK_RENAMEFROMSTR, "元の名前(&F):" + IDS_KK_RENAMETOSTR, "新しい名前(&T):" IDS_KK_HARDLINKFROMSTR, "ハードリンク元(&F):" IDS_KK_HARDLINKTOSTR, "ハードリンク先(&T):" IDS_KK_SYMLINKFROMSTR, "シンボリックリンク元(&F):" @@ -547,8 +547,8 @@ BEGIN MH_MYITEMS+IDM_MOVE, "選択アイテムを移動する" MH_MYITEMS+IDM_COPY, "ファイルまたはディレクトリをコピーする" MH_MYITEMS+IDM_COPYTOCLIPBOARD, "1つまたは複数のファイルをクリップボードにコピーする" - MH_MYITEMS+IDM_CUTTOCLIPBOARD, "1つまたは複数のファイルをクリップボードに切り取る" - MH_MYITEMS+IDM_PASTE, "現在のディレクトリにクリップボードから貼り付ける" + MH_MYITEMS+IDM_CUTTOCLIPBOARD, "1つまたは複数のファイルをクリップボードに切り取る" + MH_MYITEMS+IDM_PASTE, "現在のディレクトリにクリップボードから貼り付ける" MH_MYITEMS+IDM_COMPRESS, "ファイルまたはディレクトリを圧縮する" MH_MYITEMS+IDM_UNCOMPRESS, "ファイルまたはディレクトリを解凍する" MH_MYITEMS+IDM_DELETE, "ファイルまたはディレクトリを削除する" diff --git a/src/treectl.c b/src/treectl.c index f913503e..e80bde94 100644 --- a/src/treectl.c +++ b/src/treectl.c @@ -80,8 +80,8 @@ FindItemFromPath( HWND hwndLB, LPTSTR lpszPath, BOOL bReturnParent, - DWORD *pIndex, - PDNODE *ppNode); + DWORD *pIndex, + PDNODE *ppNode); INT BuildTreeName( @@ -176,7 +176,7 @@ GetTreePath(PDNODE pNode, LPTSTR szDest) // SetNodeAttribs -// +// // Set node attributes for directory/junction/symlink // VOID @@ -189,7 +189,7 @@ SetNodeAttribs(PDNODE pNode, LPTSTR szPath) // // Determine which kind of Reparse Point - // + // if (pNode->dwAttribs & ATTR_REPARSE_POINT) { TCHAR szTemp[MAXPATHLEN]; @@ -425,7 +425,7 @@ InsertDirectory( } else { - int iCmp; + int iCmp; do { iMid = (iMax + iMin) / 2; @@ -804,7 +804,7 @@ ReadDirLevel( iNode, dwAttribs, bFullyExpand, szAutoExpand, bPartialSort); } - BOOL bCasePreserved = IsCasePreservedDrive(DRIVEID(szPath)); + BOOL bCasePreserved = IsCasePreservedDrive(DRIVEID(szPath)); while (bFound) { if (uYieldCount & (1<nLevels + 1, nIndex, dwAttribs, FALSE, szExpand, FALSE)) { - SPC_SET_NOTREE(qFreeSpace); - } + if (!ReadDirLevel(hwndTC, pNode, szExists, pNode->nLevels + 1, nIndex, dwAttribs, FALSE, szExpand, FALSE)) { + SPC_SET_NOTREE(qFreeSpace); + } - if (FindItemFromPath(hwndLB, szDir, FALSE, NULL, &pNode)) { - // found desired path in newly expanded list; select - SendMessage(hwndLB, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)pNode); - } + if (FindItemFromPath(hwndLB, szDir, FALSE, NULL, &pNode)) { + // found desired path in newly expanded list; select + SendMessage(hwndLB, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)pNode); + } - UpdateStatus(GetParent(hwndTC)); // Redraw the Status Bar + UpdateStatus(GetParent(hwndTC)); // Redraw the Status Bar - SendMessage(hwndLB, WM_SETREDRAW, TRUE, 0L); + SendMessage(hwndLB, WM_SETREDRAW, TRUE, 0L); - InvalidateRect(hwndLB, NULL, TRUE); - UpdateWindow(hwndLB); // make this look a bit better + InvalidateRect(hwndLB, NULL, TRUE); + UpdateWindow(hwndLB); // make this look a bit better } @@ -1388,10 +1388,10 @@ FindItemFromPath( { DWORD dwIndex; LPTSTR p; - PDNODE pNode; - DWORD iPreviousNode; - PDNODE pPreviousNode; - TCHAR szElement[1 + MAXFILENAMELEN + 1]; + PDNODE pNode; + DWORD iPreviousNode; + PDNODE pPreviousNode; + TCHAR szElement[1 + MAXFILENAMELEN + 1]; BOOL bReturn = TRUE; if (pIndex) { @@ -2267,16 +2267,16 @@ TreeControlWndProc( DWORD i; if (FindItemFromPath(hwndLB, (LPTSTR)lParam, wParam != 0, &i, NULL)) - { - SendMessage(hwndLB, LB_SETCURSEL, i, 0L); - - // update dir window if it exists (which also updates MDI text) - SendMessage(hwnd, - WM_COMMAND, - GET_WM_COMMAND_MPS(IDCW_TREELISTBOX, - hwndLB, - LBN_SELCHANGE)); - } + { + SendMessage(hwndLB, LB_SETCURSEL, i, 0L); + + // update dir window if it exists (which also updates MDI text) + SendMessage(hwnd, + WM_COMMAND, + GET_WM_COMMAND_MPS(IDCW_TREELISTBOX, + hwndLB, + LBN_SELCHANGE)); + } break; } @@ -2287,34 +2287,34 @@ TreeControlWndProc( INT fDontSelChange = HIWORD(wParam); LPTSTR szDir = (LPTSTR)lParam; // NULL -> default == window text. - // - // Don't do anything while the tree is being built. - // - if (GetWindowLongPtr(hwnd, GWL_READLEVEL)) - break; + // + // Don't do anything while the tree is being built. + // + if (GetWindowLongPtr(hwnd, GWL_READLEVEL)) + break; - RECT rc; - DWORD i; - PDNODE pNode; + RECT rc; + DWORD i; + PDNODE pNode; - // do the same as TC_SETDIRECTORY above for the simple case - if (FindItemFromPath(hwndLB, (LPTSTR)lParam, 0, &i, &pNode)) - { - // found exact node already displayed; select it and continue - SendMessage(hwndLB, LB_SETCURSEL, i, 0L); + // do the same as TC_SETDIRECTORY above for the simple case + if (FindItemFromPath(hwndLB, (LPTSTR)lParam, 0, &i, &pNode)) + { + // found exact node already displayed; select it and continue + SendMessage(hwndLB, LB_SETCURSEL, i, 0L); - goto UpdateDirSelection; - } + goto UpdateDirSelection; + } - if (!fFullyExpand && pNode) - { - // expand in place if pNode != null; index (i) also set - FillOutTreeList(hwnd, szDir, i, pNode); + if (!fFullyExpand && pNode) + { + // expand in place if pNode != null; index (i) also set + FillOutTreeList(hwnd, szDir, i, pNode); - goto UpdateDirSelection; - } + goto UpdateDirSelection; + } - // else change drive (existing code) + // else change drive (existing code) // // is the drive/dir specified? @@ -2392,7 +2392,7 @@ TreeControlWndProc( cchMatch = wcslen(rgchMatch); if (cchMatch > wcslen(pNode->szName)) cchMatch = wcslen(pNode->szName); - if (CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE, + if (CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE, rgchMatch, (INT)cchMatch, pNode->szName, (INT)cchMatch) == 2) break; @@ -2417,7 +2417,7 @@ TreeControlWndProc( } { IDropTarget *pDropTarget; - + pDropTarget = (IDropTarget *)GetWindowLongPtr(hwnd, GWL_OLEDROP); if (pDropTarget != NULL) UnregisterDropWindow(hwnd, pDropTarget); @@ -2447,7 +2447,7 @@ TreeControlWndProc( { WF_IDropTarget *pDropTarget; - + RegisterDropWindow(hwnd, &pDropTarget); SetWindowLongPtr(hwnd, GWL_OLEDROP, (LPARAM)pDropTarget); } @@ -2466,11 +2466,11 @@ TreeControlWndProc( if (!lParam || wParam == FSC_REFRESH) break; - /* Did we find it? */ - if (!FindItemFromPath(hwndLB, (LPTSTR)lParam, - wParam == FSC_MKDIR || wParam == FSC_MKDIRQUIET, (DWORD*)&nIndex, &pNode)) { + /* Did we find it? */ + if (!FindItemFromPath(hwndLB, (LPTSTR)lParam, + wParam == FSC_MKDIR || wParam == FSC_MKDIRQUIET, (DWORD*)&nIndex, &pNode)) { break; - } + } lstrcpy(szPath, (LPTSTR)lParam); StripPath(szPath); @@ -2662,7 +2662,7 @@ TreeControlWndProc( SendMessage(hwndDir, FS_CHANGEDISPLAY, id, (LPARAM)szPath); } else { - // TODO: why isn't this part of TC_SETDRIVE? currently when a tree only is shown, the MDI window text is not updated + // TODO: why isn't this part of TC_SETDRIVE? currently when a tree only is shown, the MDI window text is not updated SetMDIWindowText(hwndParent, szPath); } @@ -2708,8 +2708,8 @@ TreeControlWndProc( } case WM_CONTEXTMENU: - ActivateCommonContextMenu(hwnd, hwndLB, lParam); - break; + ActivateCommonContextMenu(hwnd, hwndLB, lParam); + break; case WM_LBTRACKPOINT: { @@ -2942,7 +2942,7 @@ TreeControlWndProc( } } } - else if (GetKeyState(VK_MENU) < 0 || GetKeyState(VK_SHIFT) < 0) + else if (GetKeyState(VK_MENU) < 0 || GetKeyState(VK_SHIFT) < 0) // ALT || SHIFT forces a move even if not on same drive iOperation = DROP_MOVE; else @@ -3302,8 +3302,8 @@ BuildTreeName(LPTSTR lpszPath, INT iLen, INT iSize) // Check for \\ aka UNC if (!ISUNCPATH(lpszPath)) // Check for X:\ - if (3 != iLen || CHAR_BACKSLASH != lpszPath[2]) - return iLen; + if (3 != iLen || CHAR_BACKSLASH != lpszPath[2]) + return iLen; DRIVE drive = DRIVEID(lpszPath); diff --git a/src/wfcomman.c b/src/wfcomman.c index 2e01400e..5d01744a 100644 --- a/src/wfcomman.c +++ b/src/wfcomman.c @@ -578,10 +578,10 @@ CreateDirWindow( // call TC_SETDRIVE like use of CreateTreeWindow in NewTree() if (hwndActive && (hwndT = HasTreeWindow(hwndActive))) - SendMessage(hwndT, - TC_SETDRIVE, - MAKELONG(MAKEWORD(FALSE, 0), TRUE), - 0L); + SendMessage(hwndT, + TC_SETDRIVE, + MAKELONG(MAKEWORD(FALSE, 0), TRUE), + 0L); return hwndActive; } diff --git a/src/wfdir.c b/src/wfdir.c index 140812c4..9daa2744 100644 --- a/src/wfdir.c +++ b/src/wfdir.c @@ -883,8 +883,8 @@ DirWndProc( break; case WM_CONTEXTMENU: - ActivateCommonContextMenu(hwnd, hwndLB, lParam); - break; + ActivateCommonContextMenu(hwnd, hwndLB, lParam); + break; case WM_VKEYTOITEM: switch (GET_WM_VKEYTOITEM_CODE(wParam, lParam)) { @@ -893,10 +893,10 @@ DirWndProc( TypeAheadString('\0', NULL); return -2L; - case 'A': /* Ctrl-A */ - if (GetKeyState(VK_CONTROL) >= 0) - break; - case 0xBF: /* Ctrl-/ */ + case 'A': /* Ctrl-A */ + if (GetKeyState(VK_CONTROL) >= 0) + break; + case 0xBF: /* Ctrl-/ */ TypeAheadString('\0', NULL); SendMessage(hwndFrame, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_SELALL, 0, 0)); return -2; @@ -974,7 +974,7 @@ DirWndProc( // for WM_CREATE, wParam and lParam are ignored // for WM_FSC, wParam is FSC_* and lParam depends on the function (but the cases handled here are limited) // for FS_CHANGEDISPLAY, wParam is one of CD_* values; -// for CD_SORT, LOWORD(lParam) == sort value +// for CD_SORT, LOWORD(lParam) == sort value // for CD_VIEW, LOWORD(lParam) == view bits and HIWORD(lParam) == TRUE means always refresh // for CD_PATH and CD_PATH_FORCE, lParam is the new path; if NULL, use MDI window text @@ -1172,7 +1172,7 @@ ChangeDisplay( dwNewAttribs = (DWORD)GetWindowLongPtr(hwndListParms, GWL_ATTRIBS); SetWindowLongPtr(hwndListParms, GWL_VIEW, dwNewView); - bCreateDTABlock = FALSE; // and szPath is NOT set + bCreateDTABlock = FALSE; // and szPath is NOT set goto CreateLB; } @@ -1307,7 +1307,7 @@ ChangeDisplay( SetWindowLongPtr(hwnd, GWLP_USERDATA, 1); SendMessage(hwndLB, LB_RESETCONTENT, 0, 0L); - // bCreateDTABlock is TRUE and szPath is set + // bCreateDTABlock is TRUE and szPath is set goto CreateNewPath; } @@ -1356,7 +1356,7 @@ ChangeDisplay( // GetMDIWindowText(hwndListParms, szPath, COUNTOF(szPath)); - // bCreateDTABlock == TRUE and szPath just set + // bCreateDTABlock == TRUE and szPath just set CreateLB: @@ -1424,7 +1424,7 @@ ChangeDisplay( CreateNewPath: - if (bCreateDTABlock) { + if (bCreateDTABlock) { // // at this point szPath has the directory to read. this @@ -1434,7 +1434,7 @@ ChangeDisplay( SetWindowLongPtr(hwndListParms, GWL_TYPE, DRIVEID(szPath)); - SetMDIWindowText(hwndListParms, szPath); + SetMDIWindowText(hwndListParms, szPath); lpStart = CreateDTABlock(hwnd, szPath, diff --git a/src/wfgoto.cpp b/src/wfgoto.cpp index b68e81ed..fc01497b 100644 --- a/src/wfgoto.cpp +++ b/src/wfgoto.cpp @@ -601,39 +601,39 @@ LRESULT APIENTRY GotoEditSubclassProc( VOID SetCurrentPathOfWindow(LPWSTR szPath) { - HWND hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); - - HWND hwndNew = nullptr; - if (ISUNCPATH(szPath)) - { - // For UNC path this is the place of opening a new UNC window. - // Use CTRL+W to remove the number-drive mapping and close it - DRIVE freeDriveFound = AddUNCDrive(szPath); - switch (freeDriveFound) - { - case -1: - // UNC Loop found. Throw your favourite messagebox here - break; - - case 0: - // Out of free UNC Slots. Throw your favourite messagebox here - break; - - // drive slot found > 0 - default: - hwndNew = CreateDirWindow(szPath, FALSE, hwndActive); - if (hwndNew) - RefreshWindow(hwndNew, TRUE, TRUE); - } - } - else - hwndNew = CreateDirWindow(szPath, TRUE, hwndActive); - - HWND hwndTree = HasTreeWindow(hwndNew); - if (hwndTree) - { - SetFocus(hwndTree); - } + HWND hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); + + HWND hwndNew = nullptr; + if (ISUNCPATH(szPath)) + { + // For UNC path this is the place of opening a new UNC window. + // Use CTRL+W to remove the number-drive mapping and close it + DRIVE freeDriveFound = AddUNCDrive(szPath); + switch (freeDriveFound) + { + case -1: + // UNC Loop found. Throw your favourite messagebox here + break; + + case 0: + // Out of free UNC Slots. Throw your favourite messagebox here + break; + + // drive slot found > 0 + default: + hwndNew = CreateDirWindow(szPath, FALSE, hwndActive); + if (hwndNew) + RefreshWindow(hwndNew, TRUE, TRUE); + } + } + else + hwndNew = CreateDirWindow(szPath, TRUE, hwndActive); + + HWND hwndTree = HasTreeWindow(hwndNew); + if (hwndTree) + { + SetFocus(hwndTree); + } } INT_PTR diff --git a/src/wfutil.c b/src/wfutil.c index f9c0712c..510cf845 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -20,43 +20,43 @@ LPTSTR CurDirCache[MAX_DRIVES]; DWORD historyCur = 0; typedef struct HistoryDir { - HWND hwnd; - TCHAR szDir[MAXPATHLEN]; + HWND hwnd; + TCHAR szDir[MAXPATHLEN]; } HistoryDir; HistoryDir rghistoryDir[MAXHISTORY]; VOID SaveHistoryDir(HWND hwnd, LPWSTR szDir) { - if (rghistoryDir[historyCur].hwnd == hwnd && lstrcmpi(rghistoryDir[historyCur].szDir, szDir) == 0) - return; + if (rghistoryDir[historyCur].hwnd == hwnd && lstrcmpi(rghistoryDir[historyCur].szDir, szDir) == 0) + return; - historyCur = (historyCur + 1) % MAXHISTORY; + historyCur = (historyCur + 1) % MAXHISTORY; - rghistoryDir[historyCur].hwnd = hwnd; - lstrcpy(rghistoryDir[historyCur].szDir, szDir); + rghistoryDir[historyCur].hwnd = hwnd; + lstrcpy(rghistoryDir[historyCur].szDir, szDir); - // always leave one NULL entry after current - DWORD historyT = (historyCur + 1) % MAXHISTORY; - rghistoryDir[historyT].hwnd = NULL; - rghistoryDir[historyT].szDir[0] = '\0'; + // always leave one NULL entry after current + DWORD historyT = (historyCur + 1) % MAXHISTORY; + rghistoryDir[historyT].hwnd = NULL; + rghistoryDir[historyT].szDir[0] = '\0'; } BOOL GetPrevHistoryDir(BOOL forward, HWND *phwnd, LPWSTR szDir) { - DWORD historyNext = (historyCur + 1) % MAXHISTORY; - DWORD historyPrev = (historyCur == 0 ? MAXHISTORY : historyCur )- 1; - DWORD historyT = forward ? historyNext : historyPrev; - - if (rghistoryDir[historyT].hwnd == NULL) - return FALSE; - - historyCur = historyT; - - *phwnd = rghistoryDir[historyCur].hwnd; - lstrcpy(szDir, rghistoryDir[historyCur].szDir); - return TRUE; + DWORD historyNext = (historyCur + 1) % MAXHISTORY; + DWORD historyPrev = (historyCur == 0 ? MAXHISTORY : historyCur )- 1; + DWORD historyT = forward ? historyNext : historyPrev; + + if (rghistoryDir[historyT].hwnd == NULL) + return FALSE; + + historyCur = historyT; + + *phwnd = rghistoryDir[historyCur].hwnd; + lstrcpy(szDir, rghistoryDir[historyCur].szDir); + return TRUE; } LPWSTR @@ -209,7 +209,7 @@ GetSelectedDirectory(DRIVE drive, LPTSTR pszDir) goto hwndfound; } if (!GetSavedDirectory(drive - 1, pszDir)) { - GetDriveDirectory(drive, pszDir); + GetDriveDirectory(drive, pszDir); } return; } else @@ -263,42 +263,42 @@ BOOL GetDriveDirectory(INT iDrive, LPTSTR pszDir) VOID GetAllDirectories(LPTSTR rgszDirs[]) { - HWND mpdrivehwnd[MAX_DRIVES]; + HWND mpdrivehwnd[MAX_DRIVES]; HWND hwnd; DRIVE driveT; - for (driveT = 0; driveT < MAX_DRIVES; driveT++) - { - rgszDirs[driveT] = NULL; - mpdrivehwnd[driveT] = NULL; - } - + for (driveT = 0; driveT < MAX_DRIVES; driveT++) + { + rgszDirs[driveT] = NULL; + mpdrivehwnd[driveT] = NULL; + } + for (hwnd = GetWindow(hwndMDIClient,GW_CHILD); hwnd; hwnd = GetWindow(hwnd,GW_HWNDNEXT)) { - driveT = (DRIVE)SendMessage(hwnd,FS_GETDRIVE,0,0L) - CHAR_A; - if (mpdrivehwnd[driveT] == NULL) - mpdrivehwnd[driveT] = hwnd; - } - - for (driveT = 0; driveT < MAX_DRIVES; driveT++) - { - TCHAR szDir[MAXPATHLEN]; - - if (mpdrivehwnd[driveT] != NULL) - { - SendMessage(mpdrivehwnd[driveT],FS_GETDIRECTORY,MAXPATHLEN,(LPARAM)szDir); - - StripBackslash(szDir); - } - else if (!GetSavedDirectory(driveT, szDir)) - szDir[0] = '\0'; - - if (szDir[0] != '\0') - { - rgszDirs[driveT] = (LPTSTR) LocalAlloc(LPTR, ByteCountOf(lstrlen(szDir)+1)); - lstrcpy(rgszDirs[driveT], szDir); - } - } + driveT = (DRIVE)SendMessage(hwnd,FS_GETDRIVE,0,0L) - CHAR_A; + if (mpdrivehwnd[driveT] == NULL) + mpdrivehwnd[driveT] = hwnd; + } + + for (driveT = 0; driveT < MAX_DRIVES; driveT++) + { + TCHAR szDir[MAXPATHLEN]; + + if (mpdrivehwnd[driveT] != NULL) + { + SendMessage(mpdrivehwnd[driveT],FS_GETDIRECTORY,MAXPATHLEN,(LPARAM)szDir); + + StripBackslash(szDir); + } + else if (!GetSavedDirectory(driveT, szDir)) + szDir[0] = '\0'; + + if (szDir[0] != '\0') + { + rgszDirs[driveT] = (LPTSTR) LocalAlloc(LPTR, ByteCountOf(lstrlen(szDir)+1)); + lstrcpy(rgszDirs[driveT], szDir); + } + } } From f57d8cb13c80675f0c204ceb8fab0c9dca3d4d61 Mon Sep 17 00:00:00 2001 From: schinagl Date: Fri, 29 Sep 2023 07:18:43 +0200 Subject: [PATCH 07/14] Mention UNC path support in Readme.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8aa2bd9a..626f573f 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ selecting one changes to that directory. Default = c:\\. Configure via Winfile. 21. Can handle paths up to 1024 characters with Windows10 >= 1607. Set HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled=1 as admin. 22. Japanese localisation with full-width katakanas 23. Create files with suffix '- Copy', when copying with (`ctrl+C`) -> (`ctrl+V`) in the same dir, or drag-copy with mouse onto empty space in same dir. +24. UNC Path support via CTRL-G. Shows up as 'digit drive' 0: - 9:. Select it either via CTRL-0 ... CTRL-9 or from drive drop-down. Remove UNC digit drive with CTRL-W You can read the code for more details. From ba6b5f77e69d545293858142af1a29348dfda37e Mon Sep 17 00:00:00 2001 From: schinagl Date: Tue, 3 Oct 2023 18:51:40 +0200 Subject: [PATCH 08/14] The position of numbered drives shall be persisted too, so that numbered drives always open in the same place --- src/wfdlgs.c | 7 ++++--- src/wfinit.c | 31 +++++++++++++++++++++++++------ src/wfutil.c | 11 ++++++++--- src/winfile.h | 8 +++++--- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/wfdlgs.c b/src/wfdlgs.c index ec8fe41f..62c26fe3 100644 --- a/src/wfdlgs.c +++ b/src/wfdlgs.c @@ -106,15 +106,16 @@ SaveWindows(HWND hwndMain) GetSplit(hwnd), szPath); } else { - // For UNC path we need to save the name of the root too - wsprintf(buf2, TEXT("%ld,%ld,%ld,%ld,%ld,%ld,%u,%lu,%lu,%lu,%d,%s\"%s"), + // For UNC path we need to save the name of the root and the drive id too + wsprintf(buf2, TEXT("%ld,%ld,%ld,%ld,%ld,%ld,%u,%lu,%lu,%lu,%d,%s\"%s\"%d"), wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom, wp.ptMinPosition.x, wp.ptMinPosition.y, wp.showCmd, view, sort, attribs, GetSplit(hwnd), szPath, - aDriveInfo[drive].szRoot); + aDriveInfo[drive].szRoot, + drive - OFFSET_UNC); } // the dir is an ANSI string (?) diff --git a/src/wfinit.c b/src/wfinit.c index 6c6c7953..1e74e3de 100644 --- a/src/wfinit.c +++ b/src/wfinit.c @@ -737,15 +737,30 @@ GetSavedWindow( } // Search for an optional name of the root, which seperated by " from the directory + // and a drive number also seperated with " // e.g. - // dir1==....,\\unc\path1\*.*"\\unc\path1\aurea\prima + // dir1==....,\\unc\path1\*.*"\\unc\path1\aurea\prima"2 // It is " because is must be a character, which is not allowed in pathnames LPTSTR szDir = szBuf; while (*szBuf && *szBuf != CHAR_DQUOTE) szBuf++; if (*szBuf) { *szBuf = CHAR_NULL; - lstrcpy(pwin->szRoot, ++szBuf); // name of the root + LPCTSTR szRoot = ++szBuf; + + // Search on for the next quote + while (*szBuf && *szBuf != CHAR_DQUOTE) + szBuf++; + if (*szBuf) { + *szBuf = CHAR_NULL; + ++szBuf; // number of drive + if (*szBuf) + pwin->dwDriveNumber = atoi(szBuf); + } else + pwin->dwDriveNumber = -1; + + lstrcpy(pwin->szRoot, szRoot); // name of the root + } else { pwin->szRoot[0] = CHAR_NULL; } @@ -815,13 +830,17 @@ CreateSavedWindows() StripFilespec(szDir); StripBackslash(szDir); - if (win.szRoot[0]) + if (win.szRoot[0]) { // UNC Drive - AddUNCDrive(win.szRoot); - else + 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 (!CheckDirExists(szDir)) continue; @@ -1344,7 +1363,7 @@ JAPANEND win.rc.right -= win.rc.left; win.rc.bottom -= win.rc.top; - // We need to know about all reaprse tags + // We need to know about all reparse tags hNtdll = GetModuleHandle(NTDLL_DLL); if (hNtdll) { diff --git a/src/wfutil.c b/src/wfutil.c index 510cf845..c25a8242 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -1646,6 +1646,13 @@ DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot) return 0; } +VOID SetUNCDrive(LPTSTR path, DWORD aFreeDriveSlot) +{ + lstrcpy(aDriveInfo[aFreeDriveSlot].szRoot, path); + lstrcpy(aDriveInfo[aFreeDriveSlot].szRootBackslash, path); + AddBackslash(aDriveInfo[aFreeDriveSlot].szRootBackslash); +} + // Returns drive-id if possible. If not returns 0 // Possible failure reasons: Exceeded number of free numbered drives or UNC cirularity DRIVE AddUNCDrive(LPTSTR path) @@ -1658,9 +1665,7 @@ DRIVE AddUNCDrive(LPTSTR path) DRIVE drive = FindUNCDrive(path, &dwFreeDriveSlot); if (!drive && dwFreeDriveSlot) { // Havent't found an existing slot, so add new to first free found - lstrcpy(aDriveInfo[dwFreeDriveSlot].szRoot, path); - lstrcpy(aDriveInfo[dwFreeDriveSlot].szRootBackslash, path); - AddBackslash(aDriveInfo[dwFreeDriveSlot].szRootBackslash); + SetUNCDrive(path, dwFreeDriveSlot); drive = dwFreeDriveSlot; } diff --git a/src/winfile.h b/src/winfile.h index af186505..d25366d7 100644 --- a/src/winfile.h +++ b/src/winfile.h @@ -105,7 +105,7 @@ INT atoiW(LPWSTR sz); #define MAX_WINDOWS 27 #define MAX_UNC 10 -#define OFFSET_UNC 'Z' - 'A' + 1 +#define OFFSET_UNC ('Z' - 'A' + 1) #define MAX_DRIVES OFFSET_UNC + MAX_UNC // struct for volume info @@ -311,8 +311,9 @@ typedef struct { // // *2 since may have huge filter // - WCHAR szDir[2*MAXPATHLEN]; - WCHAR szRoot[MAXPATHLEN]; + TCHAR szDir[2*MAXPATHLEN]; + TCHAR szRoot[MAXPATHLEN]; + INT dwDriveNumber; // // Next block of fields must be together (11 DWORDS) @@ -441,6 +442,7 @@ DRIVE AddUNCDrive(LPTSTR path); DRIVE RemoveUNCDrive(LPCTSTR path); DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot); BOOL FindUNCLoop(LPCTSTR path); +VOID SetUNCDrive(LPTSTR path, DWORD aFreeDriveSlot); // WFDIR.C From 91dbf00351673b15dd8a4e59b79ba13aeada1fba Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Wed, 4 Oct 2023 08:48:23 +0200 Subject: [PATCH 09/14] Persist non open UNC drives --- src/wfdlgs.c | 4 ++++ src/wfinit.c | 2 ++ src/wfutil.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/winfile.h | 4 ++++ 4 files changed, 52 insertions(+) diff --git a/src/wfdlgs.c b/src/wfdlgs.c index 62c26fe3..04e7b5fa 100644 --- a/src/wfdlgs.c +++ b/src/wfdlgs.c @@ -116,6 +116,8 @@ SaveWindows(HWND hwndMain) szPath, aDriveInfo[drive].szRoot, drive - OFFSET_UNC); + + aDriveInfo[drive].bDirtyPersist = TRUE; } // the dir is an ANSI string (?) @@ -136,6 +138,8 @@ SaveWindows(HWND hwndMain) goto DO_AGAIN; } + SaveUNCDrives(); + // Save CachedPath and GotoCachePunctuation WritePrivateProfileString(szSettings, szCachedPath, szCachedPathIni, szTheINIFile); WritePrivateProfileString(szSettings, szGotoCachePunctuation, szPunctuation, szTheINIFile); diff --git a/src/wfinit.c b/src/wfinit.c index 1e74e3de..4389ebde 100644 --- a/src/wfinit.c +++ b/src/wfinit.c @@ -876,6 +876,8 @@ CreateSavedWindows() } while (*buf); + LoadUNCDrives(); + // // if nothing was saved create a tree for the current drive // diff --git a/src/wfutil.c b/src/wfutil.c index c25a8242..9f07c229 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -1646,10 +1646,52 @@ DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot) return 0; } +VOID SaveUNCDrives() +{ + TCHAR szUNCBuf[MAXPATHLEN]; + for (DWORD dwDriveIndex = OFFSET_UNC; dwDriveIndex < MAX_DRIVES; ++dwDriveIndex) { + + TCHAR szUNCKey[MAXPATHLEN]; + wsprintf(szUNCKey, szUNCKeyFormat, dwDriveIndex - OFFSET_UNC); + + if (aDriveInfo[dwDriveIndex].bDirtyPersist == FALSE && aDriveInfo[dwDriveIndex].szRoot[0]) + { + // For UNC path we need to save the name of the root and the drive id too + wsprintf(szUNCBuf, TEXT("%s"), + aDriveInfo[dwDriveIndex].szRoot); + + WritePrivateProfileString(szSettings, szUNCKey, szUNCBuf, szTheINIFile); + } else { + WritePrivateProfileString(szSettings, szUNCKey, NULL, szTheINIFile); + aDriveInfo[dwDriveIndex].bDirtyPersist = FALSE; + } + + } +} + +VOID LoadUNCDrives() +{ + TCHAR szUNCBuf[MAXPATHLEN]; + for (DWORD dwDriveIndex = OFFSET_UNC; dwDriveIndex < MAX_DRIVES; ++dwDriveIndex) { + + TCHAR szUNCKey[MAXPATHLEN]; + wsprintf(szUNCKey, szUNCKeyFormat, dwDriveIndex - OFFSET_UNC); + + GetPrivateProfileString(szSettings, szUNCKey, szNULL, szUNCBuf, COUNTOF(szUNCBuf), szTheINIFile); + if (szUNCBuf[0]) + SetUNCDrive(szUNCBuf, dwDriveIndex); + } +} + VOID SetUNCDrive(LPTSTR path, DWORD aFreeDriveSlot) { lstrcpy(aDriveInfo[aFreeDriveSlot].szRoot, path); lstrcpy(aDriveInfo[aFreeDriveSlot].szRootBackslash, path); + + // Force drive to be Network drive + aDriveInfo[aFreeDriveSlot].uType = DRIVE_REMOTE; + aDriveInfo[aFreeDriveSlot].iOffset = GetDriveOffset(aFreeDriveSlot); + AddBackslash(aDriveInfo[aFreeDriveSlot].szRootBackslash); } diff --git a/src/winfile.h b/src/winfile.h index d25366d7..71f74609 100644 --- a/src/winfile.h +++ b/src/winfile.h @@ -443,6 +443,8 @@ DRIVE RemoveUNCDrive(LPCTSTR path); DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot); BOOL FindUNCLoop(LPCTSTR path); VOID SetUNCDrive(LPTSTR path, DWORD aFreeDriveSlot); +VOID SaveUNCDrives(); +VOID LoadUNCDrives(); // WFDIR.C @@ -956,6 +958,7 @@ typedef struct _DRIVE_INFO { TCHAR szRoot[MAXPATHLEN]; TCHAR szRootBackslash[MAXPATHLEN]; + BOOL bDirtyPersist; } DRIVEINFO, *PDRIVEINFO; #define SC_SPLIT 100 @@ -1230,6 +1233,7 @@ Extern TCHAR szChangeNotifyTime[] EQ( TEXT("ChangeNotifyTime") ); Extern UINT uChangeNotifyTime EQ( 3000 ); Extern TCHAR szDirKeyFormat[] EQ( TEXT("dir%d") ); +Extern TCHAR szUNCKeyFormat[] EQ(TEXT("unc%d")); Extern TCHAR szWindow[] EQ( TEXT("Window") ); Extern TCHAR szWindows[] EQ( TEXT("Windows") ); From 3120383c6aaebe47ead6c88afbbd47161915dfa8 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sun, 5 Nov 2023 09:26:33 +0100 Subject: [PATCH 10/14] Allow already existing path with File.Goto and show already mapped UNC drive --- src/wfgoto.cpp | 3 ++- src/wfutil.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wfgoto.cpp b/src/wfgoto.cpp index fc01497b..9fb9c8d2 100644 --- a/src/wfgoto.cpp +++ b/src/wfgoto.cpp @@ -612,7 +612,8 @@ SetCurrentPathOfWindow(LPWSTR szPath) switch (freeDriveFound) { case -1: - // UNC Loop found. Throw your favourite messagebox here + // UNC Loop found. e.g. \\foo\bar for existing drive \\foo\bar\share + // Throw your favourite messagebox here break; case 0: diff --git a/src/wfutil.c b/src/wfutil.c index 9f07c229..6f13c7af 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -1624,8 +1624,16 @@ BOOL TypeAheadString(WCHAR ch, LPWSTR szT) BOOL FindUNCLoop(LPCTSTR path) { for (DWORD dwDriveIndex = OFFSET_UNC; dwDriveIndex < MAX_DRIVES; ++dwDriveIndex) { - if (aDriveInfo[dwDriveIndex].szRoot[0] && StrStrIW(aDriveInfo[dwDriveIndex].szRoot, path)) - return TRUE; + if (aDriveInfo[dwDriveIndex].szRoot[0] && StrStrIW(aDriveInfo[dwDriveIndex].szRoot, path)) { + + if (_wcsicmp(path, aDriveInfo[dwDriveIndex].szRoot)) + // path a was a parent of an existing drive, e.g. \\foo\bar for \\foo\bar\share + // This is a loop, which can't be handled + return TRUE; + // else + // path is the same as an existing drive, e.g. \\foo\bar for \\foo\bar + // This is o ok + } } return FALSE; } From 4425547bef6e04e8863c21238e45edce7188bf96 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sun, 5 Nov 2023 17:11:14 +0100 Subject: [PATCH 11/14] Unmap UNC drives properly even if there are many instances Take care of UNC drives beeing not the last window(s) --- src/wfcomman.c | 25 +++++++++++++------------ src/wfutil.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- src/winfile.h | 4 +++- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/wfcomman.c b/src/wfcomman.c index 5d01744a..70e21128 100644 --- a/src/wfcomman.c +++ b/src/wfcomman.c @@ -1139,21 +1139,22 @@ AppCommandProc(DWORD id) break; case IDM_CLOSEWINDOW: - { - HWND hwndActive; + { + HWND hwndActive; - hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); + hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); - if (!IsLastWindow()) { - TCHAR szPath[MAXPATHLEN]; - SendMessage(hwndActive, FS_GETDIRECTORY, COUNTOF(szPath), (LPARAM)szPath); - RemoveUNCDrive(szPath); - RefreshWindow(hwndActive, TRUE, TRUE); + SendMessage(hwndActive, FS_GETDIRECTORY, COUNTOF(szPath), (LPARAM)szPath); + if (ISUNCPATH(szPath)) + { + CloseUNCDrive(szPath); + RefreshWindow(hwndActive, TRUE, TRUE); - PostMessage(hwndActive, WM_CLOSE, 0, 0L); - } - } - break; + } + else + PostMessage(hwndActive, WM_CLOSE, 0, 0L); + } + break; case IDM_SELECT: diff --git a/src/wfutil.c b/src/wfutil.c index 6f13c7af..cbca9687 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -1691,12 +1691,12 @@ VOID LoadUNCDrives() } } -VOID SetUNCDrive(LPTSTR path, DWORD aFreeDriveSlot) +VOID SetUNCDrive(LPCTSTR path, DWORD aFreeDriveSlot) { lstrcpy(aDriveInfo[aFreeDriveSlot].szRoot, path); lstrcpy(aDriveInfo[aFreeDriveSlot].szRootBackslash, path); - // Force drive to be Network drive + // Force drive to be network drive aDriveInfo[aFreeDriveSlot].uType = DRIVE_REMOTE; aDriveInfo[aFreeDriveSlot].iOffset = GetDriveOffset(aFreeDriveSlot); @@ -1736,6 +1736,50 @@ DRIVE RemoveUNCDrive(LPCTSTR path) return dwFreeDriveSlot; } +PTCHAR GetUNCDrivePath(const DRIVE aDrive) +{ + return aDriveInfo[aDrive].szRootBackslash; +} + +// Closes the UNC mapping and all the windows showing instances of this UNC mapping +// if all instances of the UNC drive are not the last open windows +VOID CloseUNCDrive(LPCTSTR aPath) +{ + HWND hUNCSave[MAX_DRIVES] = { 0 }; + INT iWndCount = 0; + INT iUNCWndCount = 0; + INT iUNCSaveCount = 0; + + PTCHAR szUNCPath = GetUNCDrivePath(DRIVEID(aPath)); + + // Go through all non title/search windows to find instances of aPath windows + for (HWND hwnd = GetWindow(hwndMDIClient, GW_CHILD); hwnd; hwnd = GetWindow(hwnd, GW_HWNDNEXT)) { + if (!GetWindow(hwnd, GW_OWNER) && ((INT)GetWindowLongPtr(hwnd, GWL_TYPE) >= 0)) { + + TCHAR szUNCWndPath[MAX_PATH]; + SendMessage(hwnd, FS_GETDIRECTORY, COUNTOF(szUNCWndPath), (LPARAM)szUNCWndPath); + + // Check if this is an instance of the active UNC windows + if (StrStrIW(szUNCWndPath, szUNCPath)) { + iUNCWndCount++; + hUNCSave[iUNCSaveCount++] = hwnd; + } + + iWndCount++; + } + } + + // If there are more windows open than instances of the active UNC windows, we + // can close the windows and then unmap the UNC drive + if (iWndCount > iUNCWndCount) { + for (INT i = 0; i < iUNCSaveCount; ++i) + PostMessage(hUNCSave[i], WM_CLOSE, 0, 0L); + + RemoveUNCDrive(aPath); + } +} + + DRIVE DRIVEID(LPCTSTR path) { DRIVE drive = toupper(path[0]); diff --git a/src/winfile.h b/src/winfile.h index 71f74609..27656635 100644 --- a/src/winfile.h +++ b/src/winfile.h @@ -442,9 +442,11 @@ DRIVE AddUNCDrive(LPTSTR path); DRIVE RemoveUNCDrive(LPCTSTR path); DRIVE FindUNCDrive(LPCTSTR path, PDWORD pdwFreeDriveSlot); BOOL FindUNCLoop(LPCTSTR path); -VOID SetUNCDrive(LPTSTR path, DWORD aFreeDriveSlot); +VOID SetUNCDrive(LPCTSTR path, DWORD aFreeDriveSlot); VOID SaveUNCDrives(); VOID LoadUNCDrives(); +PTCHAR GetUNCDrivePath(const DRIVE aDrive); +VOID CloseUNCDrive(LPCTSTR aPath); // WFDIR.C From 26669d157f459d1ae0e26bc412cc8dd0f3c97889 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sun, 5 Nov 2023 19:26:14 +0100 Subject: [PATCH 12/14] Refresh UNC drives, otherwise the DrivesDropDown will lack the UNC drives after start of Winfile (F5 would heal this) --- src/wfinfo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wfinfo.c b/src/wfinfo.c index 6c0732ae..75960db8 100644 --- a/src/wfinfo.c +++ b/src/wfinfo.c @@ -1574,6 +1574,14 @@ UpdateDriveListComplete(VOID) if (IsRemoteDrive(drive)) { + // UNC drives always need a refresh + if (drive >= OFFSET_UNC) + { + RefreshWindow(hwnd, FALSE, FALSE); + continue; + } + + // Network drives might need a refresh if the share has changed if (!WFGetConnection(drive, &lpszVol, FALSE, ALTNAME_REG)) { lpszOldVol = (LPTSTR) GetWindowLongPtr(hwnd, GWL_VOLNAME); From 6347d1ffcc6aaee8828b05e72df4eb4bfd07e2d0 Mon Sep 17 00:00:00 2001 From: "AVL01\\SCHINAGL" Date: Mon, 29 Jan 2024 19:54:59 +0100 Subject: [PATCH 13/14] When navigating on the file pane via '..' one up, it failed on root plus one. E-.g. Going back from c:\ba via .. didn't result in showing c:\ on the left pane This only affects the UNC capable version (cherry picked from commit d81ee37bc8a4b2992ad59514003d73441c32ac9b) --- src/treectl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/treectl.c b/src/treectl.c index e80bde94..84290d39 100644 --- a/src/treectl.c +++ b/src/treectl.c @@ -1455,7 +1455,8 @@ FindItemFromPath( } while (*lpszPath); - bReturn = MatchNode(hwndLB, szElement, &dwIndex, &iPreviousNode, &pPreviousNode); + if (*szElement) + bReturn = MatchNode(hwndLB, szElement, &dwIndex, &iPreviousNode, &pPreviousNode); } else { // e.g. drive change, when root node is different than lpszPath From 471da64a503ca9a557c04d3a51ce2399049bb6c9 Mon Sep 17 00:00:00 2001 From: Hermann Schinagl Date: Sat, 8 Jun 2024 07:55:14 +0200 Subject: [PATCH 14/14] During saving of winfile.ini do not save deleted and obsolete drives (cherry picked from commit bd845d9c3751cae17f78f258e0f8dbe1288eaff5) (cherry picked from commit 1553bb097dc7137104dcff1b8a10143ec029ed7f) (cherry picked from commit 812a489e54bb7378d9d6bfd485e991ae9f0850e0) --- src/wfutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wfutil.c b/src/wfutil.c index add461f9..8d7c8b4f 100644 --- a/src/wfutil.c +++ b/src/wfutil.c @@ -1836,7 +1836,7 @@ VOID SaveUNCDrives() TCHAR szUNCKey[MAXPATHLEN]; wsprintf(szUNCKey, szUNCKeyFormat, dwDriveIndex - OFFSET_UNC); - if (aDriveInfo[dwDriveIndex].bDirtyPersist == FALSE && aDriveInfo[dwDriveIndex].szRoot[0]) + if (aDriveInfo[dwDriveIndex].bDirtyPersist == FALSE && aDriveInfo[dwDriveIndex].szRoot[0] && IsValidDisk(dwDriveIndex)) { // For UNC path we need to save the name of the root and the drive id too wsprintf(szUNCBuf, TEXT("%s"),