Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/c4520089a8468918f0e6cfaee0ba08ad81a21240
>---------------------------------------------------------------
commit c4520089a8468918f0e6cfaee0ba08ad81a21240
Author: Alex Alabuzhev <
alab...@gmail.com>
Date: Fri Jun 12 01:04:34 2026 +0100
Continue 6696.2
>---------------------------------------------------------------
c4520089a8468918f0e6cfaee0ba08ad81a21240
far/changelog | 5 +++++
far/diskmenu.cpp | 39 +++++++++++++++++++++------------------
far/farlang.templ.m4 | 26 +++++++++++++-------------
far/flink.cpp | 13 +++++++++----
far/flink.hpp | 1 +
far/vbuild.m4 | 2 +-
6 files changed, 50 insertions(+), 36 deletions(-)
diff --git a/far/changelog b/far/changelog
index 035d58252..6941f47d6 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+drkns 2026-06-12 01:04:05+01:00 - build 6698
+
+1. Continue 6696.2.
+
--------------------------------------------------------------------------------
drkns 2026-06-11 19:24:01+01:00 - build 6697
diff --git a/far/diskmenu.cpp b/far/diskmenu.cpp
index 0fd59695a..f789791a5 100644
--- a/far/diskmenu.cpp
+++ b/far/diskmenu.cpp
@@ -86,15 +86,17 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
enum
{
- DRIVE_FLAG_SUBSTITUTE = 1_bit,
- DRIVE_FLAG_REMOTE_DISCONNECTED = 2_bit,
- DRIVE_FLAG_VIRTUAL = 3_bit,
- DRIVE_FLAG_NOT_VIRTUAL = 4_bit,
+ DRIVE_FLAG_SUBSTITUTE = 0_bit,
+ DRIVE_FLAG_NOT_SUBSTITUTE = 1_bit,
+ DRIVE_FLAG_VIRTUAL = 2_bit,
+ DRIVE_FLAG_NOT_VIRTUAL = 3_bit,
+ DRIVE_FLAG_REMOTE_DISCONNECTED = 4_bit,
};
struct disk_item
{
string RootDirectory;
+ string AssociatedPath;
unsigned DriveType;
unsigned Flags;
lng Operation;
@@ -287,14 +289,14 @@ static bool MessageRemoveConnection(string_view const Drive, BoolOption& Reconne
Builder.SetId(DisconnectDriveId);
Builder.SetDialogMode(DMODE_WARNINGSTYLE);
- Builder.AddText(far::vformat(msg(lng::MChangeDriveDisconnectQuestion), Drive));
- Builder.AddText(lng::MChangeDriveDisconnectMapped);
+ Builder.AddText(far::vformat(msg(lng::MChangeDriveDisconnectQuestion), Drive)).Flags |= DIF_CENTERTEXT;
+ Builder.AddText(lng::MChangeDriveDisconnectMapped).Flags |= DIF_CENTERTEXT;
{
string strMsgText;
// TODO: check result
DriveLocalToRemoteName(false, Drive, strMsgText);
- Builder.AddText(strMsgText);
+ Builder.AddText(strMsgText).Flags |= DIF_CENTERTEXT;
Builder.AddSeparator();
}
@@ -313,15 +315,12 @@ static void remove_subst(string_view const DosDriveName, disk_item& Item, bool c
{
if (FirstAttempt && Global->Opt->Confirm.RemoveSUBST)
{
- string SubstitutedPath;
- GetSubstName(Item.DriveType, DosDriveName, SubstitutedPath);
-
if (Message(MSG_WARNING,
msg(lng::MChangeSUBSTDisconnectDriveTitle),
{
far::vformat(msg(lng::MChangeSUBSTDisconnectDriveQuestion), DosDriveName),
msg(lng::MChangeDriveDisconnectMapped),
- SubstitutedPath
+ Item.AssociatedPath
},
{ lng::MYes, lng::MNo },
{}, &SUBSTDisconnectDriveId) != message_result::first_button)
@@ -341,7 +340,9 @@ static void remove_virtual(string_view const DosDriveName, disk_item& Item, bool
if (Message(MSG_WARNING,
msg(lng::MChangeVHDDisconnectDriveTitle),
{
- far::vformat(msg(lng::MChangeVHDDisconnectDriveQuestion), DosDriveName)
+ far::vformat(msg(lng::MChangeVHDDisconnectDriveQuestion), DosDriveName),
+ msg(lng::MChangeDriveDisconnectMapped),
+ Item.AssociatedPath
},
{ lng::MYes, lng::MNo },
{}, &VHDDisconnectDriveId) != message_result::first_button)
@@ -373,8 +374,9 @@ static void DisconnectDrive(disk_item& Item, bool const FirstAttempt)
{
const auto DosDriveName = dos_drive_name(Item.RootDirectory);
- if (Item.Flags & DRIVE_FLAG_SUBSTITUTE)
+ if (Item.Flags & DRIVE_FLAG_SUBSTITUTE || (!(Item.Flags & DRIVE_FLAG_NOT_SUBSTITUTE) && GetSubstName(DosDriveName, Item.AssociatedPath)))
{
+ Item.Flags |= DRIVE_FLAG_SUBSTITUTE;
Item.Operation = lng::MChangeDriveCannotDelSubst;
return remove_subst(DosDriveName, Item, FirstAttempt);
}
@@ -387,7 +389,7 @@ static void DisconnectDrive(disk_item& Item, bool const FirstAttempt)
if (Item.Flags & DRIVE_FLAG_VIRTUAL || (!(Item.Flags & DRIVE_FLAG_NOT_VIRTUAL) && DriveCanBeVirtual(Item.DriveType)))
{
- if (string Str; GetVHDInfo(Item.RootDirectory, Str))
+ if (GetVHDInfo(Item.RootDirectory, Item.AssociatedPath))
{
Item.Flags |= DRIVE_FLAG_VIRTUAL;
Item.Operation = lng::MChangeDriveCannotDetach;
@@ -559,9 +561,10 @@ static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
if (DriveMode & (DRIVE_SHOW_TYPE | DRIVE_SHOW_ASSOCIATED_PATH))
{
// These types don't affect other checks so we can retrieve them only if needed:
- if (IsDisk && GetSubstName(NewItem.DriveType, dos_drive_name(RootDirectory), NewItem.AssociatedPath))
- NewItem.Flags |= DRIVE_FLAG_SUBSTITUTE;
- else if ((DriveMode & DRIVE_SHOW_VIRTUAL) && DriveCanBeVirtual(NewItem.DriveType))
+ if (IsDisk)
+ NewItem.Flags |= GetSubstName(NewItem.DriveType, dos_drive_name(RootDirectory), NewItem.AssociatedPath)? DRIVE_FLAG_SUBSTITUTE : DRIVE_FLAG_NOT_SUBSTITUTE;
+
+ if ((DriveMode & DRIVE_SHOW_VIRTUAL) && !(NewItem.Flags & DRIVE_FLAG_SUBSTITUTE) && DriveCanBeVirtual(NewItem.DriveType))
NewItem.Flags |= GetVHDInfo(RootDirectory, NewItem.AssociatedPath)? DRIVE_FLAG_VIRTUAL : DRIVE_FLAG_NOT_VIRTUAL;
if (DriveMode & DRIVE_SHOW_TYPE)
@@ -751,7 +754,7 @@ static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
append(ItemName, Separator(), i.AssociatedPath);
}
- disk_menu_item item{ disk_item{i.RootDirectory, i.DriveType, i.Flags} };
+ disk_menu_item item{ disk_item{i.RootDirectory, i.AssociatedPath, i.DriveType, i.Flags} };
inplace::escape_ampersands(ItemName);
ItemName.insert(0, 1, L'&');
diff --git a/far/farlang.templ.m4 b/far/farlang.templ.m4
index b808015a0..a02956a51 100644
--- a/far/farlang.templ.m4
+++ b/far/farlang.templ.m4
@@ -17163,19 +17163,19 @@ upd:"Disconnect network drive"
upd:"Disconnect network drive"
MChangeDriveDisconnectQuestion
-"Вы хотите удалить соединение с устройством {0}?"
-"Do you want to disconnect from the drive {0}?"
-"Chcete odpojit od jednotky {0}?"
-"Wollen Sie die Verbindung zu Laufwerk {0} trennen?"
-"Le akar válni {0} meghajtóról?"
-"Czy odłączyć dysk {0}?"
-"Quiere desconectarse desde la unidad {0}?"
-"Chcete odpojiť od jednotky {0}?"
-"Vuoi Disconnetterti Il Disco {0}?"
-"Ви бажаєте видалити з'єднання з пристроєм {0}?"
-"Вы жадаеце выдаліць сувязь з прыстасаваннем {0}?"
-upd:"Do you want to disconnect from the drive {0}?"
-upd:"Do you want to disconnect from the drive {0}?"
+"Удалить соединение с устройством {0}?"
+"Disconnect from the drive {0}?"
+"Odpojit od jednotky {0}?"
+"Verbindung zu Laufwerk {0} trennen?"
+"Le válni {0} meghajtóról?"
+"Odłączyć dysk {0}?"
+"Desconectar de la unidad {0}?"
+"Odpojiť od jednotky {0}?"
+"Disconnetterti Il Disco {0}?"
+"Видалити з'єднання з пристроєм {0}?"
+"Выдаліць сувязь з прыстасаваннем {0}?"
+upd:"Disconnect from the drive {0}?"
+upd:"Disconnect from the drive {0}?"
MChangeDriveDisconnectMapped
"На устройство отображена папка:"
diff --git a/far/flink.cpp b/far/flink.cpp
index 2e22df2f7..7ad168dd0 100644
--- a/far/flink.cpp
+++ b/far/flink.cpp
@@ -565,6 +565,11 @@ bool GetSubstName(int DriveType, string_view const Path, string &strTargetPath)
if ((DriveRemovable && !CheckRemovable) || (!DriveRemovable && !CheckOther))
return false;
+ return GetSubstName(Path, strTargetPath);
+}
+
+bool GetSubstName(string_view const Path, string& TargetPath)
+{
const auto Type = ParsePath(Path);
if (Type != root_type::drive_letter)
return false;
@@ -575,15 +580,15 @@ bool GetSubstName(int DriveType, string_view const Path, string &strTargetPath)
if (!os::fs::QueryDosDevice(Drive, Device))
return false;
- if (starts_with_icase(Device, L"\\??\\UNC\\"sv))
+ if (const auto Prefix = L"\\??\\UNC\\"sv; starts_with_icase(Device, Prefix))
{
- strTargetPath = concat(L"\\\\"sv, string_view(Device).substr(8));
+ TargetPath = concat(L"\\\\"sv, string_view(Device).substr(Prefix.size()));
return true;
}
- if (Device.starts_with(L"\\??\\"sv))
+ if (const auto Prefix = L"\\??\\"sv; starts_with_icase(Device, Prefix))
{
- strTargetPath.assign(Device, 4);
+ TargetPath.assign(Device, Prefix.size());
return true;
}
diff --git a/far/flink.hpp b/far/flink.hpp
index 429359cd2..816e10e8e 100644
--- a/far/flink.hpp
+++ b/far/flink.hpp
@@ -70,6 +70,7 @@ bool ModifyReparsePoint(string_view Object, string_view Target);
bool GetReparsePointInfo(string_view Object, string& DestBuffer, DWORD* ReparseTag = {}, bool* IsEditable = {});
bool GetSubstName(int DriveType, string_view Path, string& strTargetPath);
+bool GetSubstName(string_view Path, string& TargetPath);
bool GetVHDInfo(string_view RootDirectory, string &strVolumePath, VIRTUAL_STORAGE_TYPE* StorageType = nullptr);
bool detach_vhd(string_view RootDirectory, bool& IsVhd);
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index 59c887495..5ee999396 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6697
+6698