Skip to content

Commit

Permalink
Show device name in Attributes dialog invoked on a device
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Nov 22, 2024
1 parent c074f7a commit c78e41f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 2024-11-22 19:07:44+00:00 - build 6394

1. Show device name in Attributes dialog invoked on a device.

--------------------------------------------------------------------------------
drkns 2024-11-21 22:53:34+00:00 - build 6393

Expand Down
14 changes: 14 additions & 0 deletions far/farlang.templ.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16568,6 +16568,20 @@ upd:"Unknown reparse point"
"Невядомая кропка паўторнага аналізу"
upd:"Unknown reparse point"

MSetAttrDiskDevice
"Устройство:"
"Device:"
"Přístroj:"
"Gerät:"
"Eszköz:"
"Urządzenie:"
"Dispositivo:"
"Zariadenie:"
"Dispositivo:"
"Пристрій:"
"Прылада:"
"Įrenginys:"

MSetAttrReadOnly
"&Только для чтения"
"&Read only"
Expand Down
46 changes: 34 additions & 12 deletions far/setattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ enum SETATTRDLG
SA_TEXT_REPARSE_POINT,
SA_EDIT_REPARSE_POINT,
SA_COMBO_REPARSE_POINT,
SA_TEXT_DEVICE,
SA_EDIT_DEVICE,
SA_SEPARATOR_AFTER_HEADER,

SA_ATTR_FIRST,
Expand Down Expand Up @@ -722,6 +724,8 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
{ DI_TEXT, {{5, 3 }, {17, 3 }}, DIF_HIDDEN, },
{ DI_EDIT, {{18, 3 }, {DlgX-6, 3 }}, DIF_HIDDEN | DIF_EDITPATH, },
{ DI_COMBOBOX, {{18, 3 }, {DlgX-6, 3 }}, DIF_SHOWAMPERSAND | DIF_DROPDOWNLIST | DIF_LISTWRAPMODE | DIF_HIDDEN, },
{ DI_TEXT, {{5, 3 }, {17, 3 }}, DIF_HIDDEN, msg(lng::MSetAttrDiskDevice), },
{ DI_EDIT, {{18, 3 }, {DlgX-6, 3 }}, DIF_HIDDEN | DIF_READONLY, },
{ DI_TEXT, {{-1, 4 }, {0, 4 }}, DIF_SEPARATOR, },

{ DI_CHECKBOX, {{C1, 5 }, {0, 5 }}, DIF_FOCUS, msg(AttributeMap[SA_CHECKBOX_READONLY - SA_ATTR_FIRST].LngId), },
Expand Down Expand Up @@ -924,7 +928,7 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
}
}

const auto IsMountPoint = [&]
const auto IsDriveLetterPath = [&]
{
if (DlgParam.Plugin)
return false;
Expand All @@ -934,12 +938,11 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
if (!IsRoot)
return false;

if (none_of(PathType, root_type::drive_letter, root_type::win32nt_drive_letter))
return false;

return os::fs::GetVolumeNameForVolumeMountPoint(SingleSelFileName, strLinkName);
return any_of(PathType, root_type::drive_letter, root_type::win32nt_drive_letter);
}();

const auto IsMountPoint = IsDriveLetterPath && os::fs::GetVolumeNameForVolumeMountPoint(SingleSelFileName, strLinkName);

if ((SingleSelFindData.Attributes != INVALID_FILE_ATTRIBUTES && (SingleSelFindData.Attributes & FILE_ATTRIBUTE_REPARSE_POINT)) || IsMountPoint)
{
LinkPresent = true;
Expand Down Expand Up @@ -1037,12 +1040,8 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)

for (auto& i: AttrDlg | std::views::drop(SA_TEXT_REPARSE_POINT))
{
i.Y1++;

if (i.Y2)
{
i.Y2++;
}
++i.Y1;
++i.Y2;
}

AttrDlg[SA_TEXT_REPARSE_POINT].Flags &= ~DIF_HIDDEN;
Expand Down Expand Up @@ -1110,7 +1109,30 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
}
}

AttrDlg[SA_TEXT_NAME].strData = QuoteOuterSpace(SingleSelFileName);
if (IsDriveLetterPath)
{
const auto DriveLetter = HasPathPrefix(SingleSelFileName)? SingleSelFileName[L"\\\\?\\"sv.size()] : SingleSelFileName.front();

AttrDlg[SA_TEXT_NAME].strData = os::fs::drive::get_root_directory(DriveLetter);

if (string Device; os::fs::QueryDosDevice(os::fs::drive::get_device_path(DriveLetter), Device))
{
++DlgY;
++AttrDlg[SA_DOUBLEBOX].Y2;

for (auto& i: AttrDlg | std::views::drop(SA_TEXT_DEVICE))
{
++i.Y1;
++i.Y2;
}

AttrDlg[SA_TEXT_DEVICE].Flags &= ~DIF_HIDDEN;
AttrDlg[SA_EDIT_DEVICE].Flags &= ~DIF_HIDDEN;
AttrDlg[SA_EDIT_DEVICE].strData = Device;
}
}
else
AttrDlg[SA_TEXT_NAME].strData = QuoteOuterSpace(SingleSelFileName);

const auto ComputerName = ExtractComputerName(SrcPanel?
SrcPanel->GetCurDir() :
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6393
6394

0 comments on commit c78e41f

Please sign in to comment.