Skip to content

Commit

Permalink
"System properties" in Attributes dialog invoked on a device didn't w…
Browse files Browse the repository at this point in the history
…ork in old Windows versions
  • Loading branch information
alabuzhev committed Dec 26, 2024
1 parent 469da19 commit bbf3e9b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 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-12-26 18:04:08+00:00 - build 6407

1. "System properties" in Attributes dialog invoked on a device didn't work in old Windows versions.

--------------------------------------------------------------------------------
drkns 2024-12-26 11:25:55+00:00 - build 6406

Expand Down
36 changes: 30 additions & 6 deletions far/setattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
DlgY += 2;
};

wchar_t DriveLetter{};

if (SelCount == 1) // !SrcPanel goes here too
{
if (!DlgParam.Plugin)
Expand Down Expand Up @@ -938,7 +940,19 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
if (!IsRoot)
return false;

return any_of(PathType, root_type::drive_letter, root_type::win32nt_drive_letter);
switch (PathType)
{
case root_type::drive_letter:
DriveLetter = SingleSelFileName.front();
return true;

case root_type::win32nt_drive_letter:
DriveLetter = SingleSelFileName[L"\\\\?\\"sv.size()];
return true;

default:
return false;
}
}();

const auto IsMountPoint = IsDriveLetterPath && os::fs::GetVolumeNameForVolumeMountPoint(SingleSelFileName, strLinkName);
Expand Down Expand Up @@ -1111,8 +1125,6 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)

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))
Expand Down Expand Up @@ -1436,11 +1448,23 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
SHELLEXECUTEINFO seInfo{ sizeof(seInfo) };
seInfo.nShow = SW_SHOW;
seInfo.fMask = SEE_MASK_INVOKEIDLIST;
auto strFullName = SingleSelFileName;
if(SingleSelFindData.Attributes&FILE_ATTRIBUTE_DIRECTORY)

string strFullName;

if (DriveLetter)
{
// \\?\X:\ doesn't work on old Windows versions
// X: works everywhere
strFullName = os::fs::drive::get_device_path(DriveLetter);
}
else
{
AddEndSlash(strFullName);
strFullName = SingleSelFileName;

if (SingleSelFindData.Attributes & FILE_ATTRIBUTE_DIRECTORY)
AddEndSlash(strFullName);
}

seInfo.lpFile = strFullName.c_str();
seInfo.lpVerb = L"properties";
const auto strCurDir = os::fs::get_current_directory();
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6406
6407

0 comments on commit bbf3e9b

Please sign in to comment.