[FarGroup/FarManager] master: Shift+F6 in Disk Menu changes the volume label (also gh-1072) (f9da07b91)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Feb 7, 2026, 3:00:54 PMFeb 7
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/f9da07b919592e599d2c6390dc6b0816b20e0503

>---------------------------------------------------------------

commit f9da07b919592e599d2c6390dc6b0816b20e0503
Author: Alex Alabuzhev <alab...@gmail.com>
Date: Sat Feb 7 19:44:46 2026 +0000

Shift+F6 in Disk Menu changes the volume label (also gh-1072)


>---------------------------------------------------------------

f9da07b919592e599d2c6390dc6b0816b20e0503
far/FarCze.hlf.m4 | 2 ++
far/FarEng.hlf.m4 | 2 ++
far/FarGer.hlf.m4 | 2 ++
far/FarHun.hlf.m4 | 2 ++
far/FarPol.hlf.m4 | 2 ++
far/FarRus.hlf.m4 | 2 ++
far/FarSky.hlf.m4 | 2 ++
far/FarUkr.hlf.m4 | 2 ++
far/changelog | 5 +++++
far/diskmenu.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
far/elevation.cpp | 27 +++++++++++++++++++++++++++
far/elevation.hpp | 4 +---
far/farlang.templ.m4 | 30 ++++++++++++++++++++++++++++++
far/platform.fs.cpp | 18 ++++++++++++++++++
far/platform.fs.hpp | 6 ++++++
far/vbuild.m4 | 2 +-
16 files changed, 152 insertions(+), 5 deletions(-)

diff --git a/far/FarCze.hlf.m4 b/far/FarCze.hlf.m4
index fbaf05a6d..fb90b0b51 100644
--- a/far/FarCze.hlf.m4
+++ b/far/FarCze.hlf.m4
@@ -3728,6 +3728,8 @@ ne pro pluginy).

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# allows to refresh the disk selection menu.

If "#CD drive type#" mode is enabled (#Ctrl+8#), Far will attempt to
diff --git a/far/FarEng.hlf.m4 b/far/FarEng.hlf.m4
index 675f02550..1c516ecdf 100644
--- a/far/FarEng.hlf.m4
+++ b/far/FarEng.hlf.m4
@@ -3695,6 +3695,8 @@ plugins).

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# allows to refresh the disk selection menu.

If "#CD drive type#" mode is enabled (#Ctrl+8#), Far will attempt to
diff --git a/far/FarGer.hlf.m4 b/far/FarGer.hlf.m4
index ab3ca9fec..963e1934a 100644
--- a/far/FarGer.hlf.m4
+++ b/far/FarGer.hlf.m4
@@ -3770,6 +3770,8 @@ plugins).

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# allows to refresh the disk selection menu.

If "#CD drive type#" mode is enabled (#Ctrl+8#), Far will attempt to
diff --git a/far/FarHun.hlf.m4 b/far/FarHun.hlf.m4
index f2be86eac..7f0d47e13 100644
--- a/far/FarHun.hlf.m4
+++ b/far/FarHun.hlf.m4
@@ -3787,6 +3787,8 @@ pluginnel emulált fájlrendszereknél nem).

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
A #Ctrl+R# frissíti a Meghajtók menü tartalmát.

Ha a #CD meghajtó típusa# mód engedélyezve van (#Ctrl+8#), a Far
diff --git a/far/FarPol.hlf.m4 b/far/FarPol.hlf.m4
index 583225498..e609d744d 100644
--- a/far/FarPol.hlf.m4
+++ b/far/FarPol.hlf.m4
@@ -3699,6 +3699,8 @@ główny folder wybranego dysku (działa tylko dla dysków, a dla wtyczek).

#Ctrl+H# pokazuje odłączone (odmapowane) wolumeny.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# pozwala odświeżyć menu wyboru dysku.

Jeżeli tryb #Parametry dysku optycznego# jest włączony (#Ctrl+8#), Far próbuje
diff --git a/far/FarRus.hlf.m4 b/far/FarRus.hlf.m4
index 3d7319c9c..7f8a4bf63 100644
--- a/far/FarRus.hlf.m4
+++ b/far/FarRus.hlf.m4
@@ -3747,6 +3747,8 @@ $ #Меню выбора диска#

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# позволяет обновить меню выбора диска.

Если включён показ параметров компакт-дисков (#Ctrl+8#), то Far будет
diff --git a/far/FarSky.hlf.m4 b/far/FarSky.hlf.m4
index 53793408a..6cdef9f2d 100644
--- a/far/FarSky.hlf.m4
+++ b/far/FarSky.hlf.m4
@@ -3690,6 +3690,8 @@ plugins).

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# allows to refresh the disk selection menu.

If "#CD drive type#" mode is enabled (#Ctrl+8#), Far will attempt to
diff --git a/far/FarUkr.hlf.m4 b/far/FarUkr.hlf.m4
index e895d300a..3bd26c169 100644
--- a/far/FarUkr.hlf.m4
+++ b/far/FarUkr.hlf.m4
@@ -3752,6 +3752,8 @@ of this information.

#Ctrl+H# shows unmapped volumes.

+ #Shift+F6# allows to change the volume label.
+
#Ctrl+R# дозволяє обновити меню вибору диска.

If "#CD drive type#" mode is enabled (#Ctrl+8#), Far will attempt to
diff --git a/far/changelog b/far/changelog
index 6cd97d500..8bd2dae89 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+drkns 2026-02-07 19:42:24+00:00 - build 6643
+
+1. Shift+F6 in Disk Menu changes the volume label (also gh-1072).
+
--------------------------------------------------------------------------------
drkns 2026-02-04 20:37:59+00:00 - build 6642

diff --git a/far/diskmenu.cpp b/far/diskmenu.cpp
index 4f31e6a79..2759b72d3 100644
--- a/far/diskmenu.cpp
+++ b/far/diskmenu.cpp
@@ -665,6 +665,42 @@ static string GetShellName(string_view const RootDirectory)
L""s;
}

+static bool rename_volume(string_view const Path)
+{
+ string Label;
+ if (!os::fs::GetVolumeInformation(Path, &Label, {}, {}, {}, {}))
+ {
+ const auto ErrorState = os::last_error();
+ Message(MSG_WARNING, ErrorState,
+ msg(lng::MError),
+ {
+ },
+ { lng::MOk });
+
+ return false;
+ }
+
+ DialogBuilder Builder(lng::MChangeDriveVolumeLabel);
+ Builder.AddEditField(Label, 32);
+ Builder.AddOKCancel();
+
+ if (!Builder.ShowDialog())
+ return false;
+
+ if (os::fs::set_volume_label(Path, Label))
+ return true;
+
+ const auto ErrorState = os::last_error();
+
+ Message(MSG_WARNING, ErrorState,
+ msg(lng::MError),
+ {
+ },
+ { lng::MOk });
+
+ return false;
+}
+
static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
{
const auto PanelRect = Owner->GetPosition();
@@ -1038,7 +1074,6 @@ static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
break;

std::visit(overload{[&](disk_item const& item)
-
{
bool Cancelled = false;
if (DisconnectDrive(Owner, item, *ChDisk, Cancelled))
@@ -1254,6 +1289,18 @@ static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
RetCode = SelPos;
break;

+ case KEY_SHIFTF6:
+ if (!MenuItem)
+ break;
+
+ std::visit(overload{[&](disk_item const& item)
+ {
+ if (rename_volume(item.Path))
+ RetCode = SelPos;
+ },
+ [](plugin_item const&){}}, *MenuItem);
+ break;
+
default:
KeyProcessed = 0;
}
diff --git a/far/elevation.cpp b/far/elevation.cpp
index ffd48dbd6..10e18e246 100644
--- a/far/elevation.cpp
+++ b/far/elevation.cpp
@@ -97,6 +97,7 @@ enum ELEVATION_COMMAND: int
C_FUNCTION_GETFILESECURITY,
C_FUNCTION_SETFILESECURITY,
C_FUNCTION_RESETFILESECURITY,
+ C_FUNCTION_SETVOLUMELABEL,

C_COMMANDS_COUNT
};
@@ -998,6 +999,21 @@ bool elevation::reset_file_security(string const& Object)
});
}

+bool elevation::set_volume_label(string const& Object, string const& Label)
+{
+ return execute(lng::MElevationRequiredSetVolumeLabel, Object,
+ false,
+ [&]
+ {
+ return os::fs::low::set_volume_label(Object.c_str(), Label.c_str());
+ },
+ [&]
+ {
+ Write(C_FUNCTION_SETVOLUMELABEL, Object, Label);
+ return RetrieveLastErrorAndResult<bool>();
+ });
+}
+
elevation::suppress::suppress(bool const Completely):
m_owner(Global? &instance() : nullptr),
m_Completely(Completely)
@@ -1342,6 +1358,16 @@ private:
Write(os::last_error(), Result);
}

+ void SetVolumeLabelHandler() const
+ {
+ const auto Object = Read<string>();
+ const auto Label = Read<string>();
+
+ const auto Result = os::fs::low::set_volume_label(Object.c_str(), Label.c_str());
+
+ Write(os::last_error(), Result);
+ }
+
static DWORD CALLBACK CopyProgressRoutineWrapper(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD StreamNumber, DWORD CallbackReason, HANDLE SourceFile,HANDLE DestinationFile, LPVOID Data)
{
const auto Param = static_cast<callback_param*>(Data);
@@ -1403,6 +1429,7 @@ private:
&elevated::GetFileSecurityHandler,
&elevated::SetFileSecurityHandler,
&elevated::ResetFileSecurityHandler,
+ &elevated::SetVolumeLabelHandler,
};

static_assert(Handlers.size() == C_COMMANDS_COUNT);
diff --git a/far/elevation.hpp b/far/elevation.hpp
index 116289547..8287fd68e 100644
--- a/far/elevation.hpp
+++ b/far/elevation.hpp
@@ -76,19 +76,17 @@ public:
os::fs::attributes get_file_attributes(const string& Object);
bool set_file_attributes(const string& Object, os::fs::attributes FileAttributes);
bool create_hard_link(const string& Object, const string& Target, SECURITY_ATTRIBUTES* SecurityAttributes);
-
bool fCreateSymbolicLink(string_view Object, string_view Target, DWORD Flags);
bool fMoveToRecycleBin(string_view Object);
bool fSetOwner(const string& Computer, const string& Object, const string& Owner);
-
HANDLE create_file(const string& Object, DWORD DesiredAccess, DWORD ShareMode, SECURITY_ATTRIBUTES* SecurityAttributes, DWORD CreationDistribution, DWORD FlagsAndAttributes, HANDLE TemplateFile);
bool set_file_encryption(const string& Object, bool Encrypt);
bool detach_virtual_disk(const string& Object, VIRTUAL_STORAGE_TYPE& VirtualStorageType);
bool get_disk_free_space(const string& Object, unsigned long long* FreeBytesAvailableToCaller, unsigned long long* TotalNumberOfBytes, unsigned long long* TotalNumberOfFreeBytes);
-
os::security::descriptor get_file_security(string const& Object, SECURITY_INFORMATION RequestedInformation);
bool set_file_security(string const& Object, SECURITY_INFORMATION RequestedInformation, os::security::descriptor const& Descriptor);
bool reset_file_security(string const& Object);
+ bool set_volume_label(const string& Object, const string& Label);

class suppress
{
diff --git a/far/farlang.templ.m4 b/far/farlang.templ.m4
index da794e76e..106285368 100644
--- a/far/farlang.templ.m4
+++ b/far/farlang.templ.m4
@@ -17478,6 +17478,21 @@ upd:"Detect virtual disks"
upd:"Detect virtual disks"
upd:"Detect virtual disks"

+MChangeDriveVolumeLabel
+"Метка тома"
+"Volume label"
+"Popisek svazku"
+"Volume Label"
+"Kötetcímke"
+"Etykieta"
+"Etiqueta de volumen"
+"Označenie zväzku"
+"Etichetta volume"
+"Позначка тому"
+"Метка тома"
+"Tomo etiketė"
+"Etiqueta do volume"
+
MSearchFileTitle
l:
"Поиск"
@@ -32052,6 +32067,21 @@ upd:"to decrypt this object:"
upd:"to decrypt this object:"
upd:"to decrypt this object:"

+MElevationRequiredSetVolumeLabel
+upd:"to set volume label:"
+"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+upd:"to set volume label:"
+
MElevationDoForAll
"Выполнить это действие для &всех текущих объектов"
"Do this for &all current objects"
diff --git a/far/platform.fs.cpp b/far/platform.fs.cpp
index 45966c104..05045d19f 100644
--- a/far/platform.fs.cpp
+++ b/far/platform.fs.cpp
@@ -1870,6 +1870,11 @@ WARNING_POP()
SetLastError(Result);
return Result == ERROR_SUCCESS && !fop.fAnyOperationsAborted;
}
+
+ bool set_volume_label(const wchar_t* Object, const wchar_t* Label)
+ {
+ return SetVolumeLabel(Object, Label) != FALSE;
+ }
}

//-------------------------------------------------------------------------
@@ -2428,6 +2433,19 @@ WARNING_POP()
return false;
}

+ bool set_volume_label(string_view const Object, string const& Label)
+ {
+ const auto NtObject = nt_path(Object);
+
+ if (low::set_volume_label(NtObject.c_str(), Label.c_str()))
+ return true;
+
+ if (ElevationRequired(ELEVATION_MODIFY_REQUEST))
+ return elevation::instance().set_volume_label(NtObject, Label);
+
+ return false;
+ }
+
bool get_disk_size(const string_view Path, unsigned long long* const UserTotal, unsigned long long* const TotalFree, unsigned long long* const UserFree)
{
auto strPath = nt_path(Path);
diff --git a/far/platform.fs.hpp b/far/platform.fs.hpp
index 5fc130653..b9d12e699 100644
--- a/far/platform.fs.hpp
+++ b/far/platform.fs.hpp
@@ -510,6 +510,9 @@ namespace os::fs

[[nodiscard]]
bool move_to_recycle_bin(string_view Object);
+
+ [[nodiscard]]
+ bool set_volume_label(const wchar_t* Object, const wchar_t* Label);
}

[[nodiscard]]
@@ -607,6 +610,9 @@ namespace os::fs
[[nodiscard]]
bool move_to_recycle_bin(string_view Object);

+ [[nodiscard]]
+ bool set_volume_label(string_view Object, string const& Label);
+
[[nodiscard]]
bool get_disk_size(string_view Path, unsigned long long* UserTotal, unsigned long long* TotalFree, unsigned long long* UserFree);

diff --git a/far/vbuild.m4 b/far/vbuild.m4
index b853b0732..9e97342c5 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6642
+6643


Reply all
Reply to author
Forward
0 new messages