Skip to content

Commit

Permalink
setattr (Ctrl-A) count devices + disable attributes/flags if was error
Browse files Browse the repository at this point in the history
  • Loading branch information
akruphi committed Jan 4, 2025
1 parent 4ae9458 commit 473f025
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
11 changes: 11 additions & 0 deletions far2l/bootstrap/scripts/farlang.templ.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16435,6 +16435,17 @@ upd:"selected %d items"
upd:"selected %d items"
upd:"selected %d items"

SetAttrInfoSelDevices
"%lsустройств: %d"
"%lsdevices: %d"
upd:"%lsdevices: %d"
upd:"%lsdevices: %d"
upd:"%lsdevices: %d"
upd:"%lsdevices: %d"
upd:"%lsdevices: %d"
upd:"%lsdevices: %d"
upd:"%lsdevices: %d"

SetAttrInfoSelDirs
"%lsкаталогов: %d"
"%lsdirs: %d"
Expand Down
31 changes: 25 additions & 6 deletions far2l/src/setattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,11 +1139,12 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)
AttrDlg[SA_FIXEDIT_LAST_ACCESS_TIME].strMask = AttrDlg[SA_FIXEDIT_LAST_MODIFICATION_TIME].strMask =
AttrDlg[SA_FIXEDIT_LAST_CHANGE_TIME].strMask = strTMask;
bool FolderPresent = false;//, LinkPresent = false;
int FolderCount = 0, Link2FileCount = 0, Link2DirCount = 0;
int FolderCount = 0, Link2FileCount = 0, Link2DirCount = 0, DeviceCount = 0, FSFileFlagsErrno = 0;
FARString strLinkName;

if (SelCount == 1) {
FSFileFlagsSafe FFFlags(strSelName.GetMB(), FileAttr);
FSFileFlagsErrno = FFFlags.Errno();
if (FileAttr & FILE_ATTRIBUTE_REPARSE_POINT) {
DlgParam.SymlinkButtonTitles[0] = Msg::SetAttrSymlinkObject;
DlgParam.SymlinkButtonTitles[1] = Msg::SetAttrSymlinkObjectInfo;
Expand All @@ -1165,9 +1166,8 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)
AttrDlg[SA_EDIT_INFO].strData = Msg::FileFilterAttrDevFIFO;
else if (FileAttr & FILE_ATTRIBUTE_DEVICE_SOCK)
AttrDlg[SA_EDIT_INFO].strData = Msg::FileFilterAttrDevSock;
else {
else
AttrDlg[SA_EDIT_INFO].strData = BriefInfo(strSelName);
}


if (FileAttr & FILE_ATTRIBUTE_DIRECTORY) {
Expand Down Expand Up @@ -1272,7 +1272,7 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)
SrcPanel->GetSelName(nullptr, FileAttr, FileMode);
}
FolderPresent = false;
FolderCount = 0; Link2FileCount = 0; Link2DirCount = 0;
FolderCount = 0; Link2FileCount = 0; Link2DirCount = 0; DeviceCount = 0;

if (SrcPanel) {
FARString strComputerName;
Expand All @@ -1299,6 +1299,8 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)
}
else if (FileAttr & FILE_ATTRIBUTE_REPARSE_POINT)
Link2FileCount++;
else if (FileAttr & FILE_ATTRIBUTE_DEVICE)
DeviceCount++;

for (size_t i = 0; i < ARRAYSIZE(AP); i++) {
if (FileMode & AP[i].Mode) {
Expand All @@ -1309,6 +1311,8 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)
CheckFileOwnerGroup(AttrDlg[SA_COMBO_GROUP], GetFileGroup, strComputerName, strSelName);

FSFileFlagsSafe FFFlags(strSelName.GetMB(), FileAttr);
if( FFFlags.Errno() != 0 ) // last errno if was error
FSFileFlagsErrno = FFFlags.Errno();
if (FFFlags.Immutable())
AttrDlg[SA_CHECKBOX_IMMUTABLE].Selected++;
if (FFFlags.Append())
Expand Down Expand Up @@ -1357,8 +1361,10 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)

{
FARString strTmp, strSep=L" (";
int FilesCount = SelCount-FolderCount-Link2FileCount-Link2DirCount;
int FilesCount = SelCount-DeviceCount-FolderCount-Link2FileCount-Link2DirCount;
strTmp.Format(Msg::SetAttrInfoSelAll, SelCount);
if (DeviceCount>0)
{ strTmp.AppendFormat(Msg::SetAttrInfoSelDevices, strSep.CPtr(), DeviceCount); strSep=L", "; }
if (FolderCount>0)
{ strTmp.AppendFormat(Msg::SetAttrInfoSelDirs, strSep.CPtr(), FolderCount); strSep=L", "; }
if (FilesCount>0)
Expand Down Expand Up @@ -1410,7 +1416,20 @@ bool ShellSetFileAttributes(Panel *SrcPanel, LPCWSTR Object)

DlgParam.strOwner = AttrDlg[SA_COMBO_OWNER].strData;
DlgParam.strGroup = AttrDlg[SA_COMBO_GROUP].strData;
DlgParam.strInitOwner = DlgParam.strOwner; DlgParam.strInitGroup = DlgParam.strGroup;
DlgParam.strInitOwner = DlgParam.strOwner;
DlgParam.strInitGroup = DlgParam.strGroup;

// if was error during obtain attributes / flags make it disabled
if (FSFileFlagsErrno != 0) {
AttrDlg[SA_TEXT_IMMUTABLE_CHMARK].Flags|= DIF_DISABLE;
AttrDlg[SA_CHECKBOX_IMMUTABLE].Flags|= DIF_DISABLE;
AttrDlg[SA_TEXT_APPEND_CHMARK].Flags|= DIF_DISABLE;
AttrDlg[SA_CHECKBOX_APPEND].Flags|= DIF_DISABLE;
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
AttrDlg[SA_TEXT_HIDDEN_CHMARK].Flags|= DIF_DISABLE;
AttrDlg[SA_CHECKBOX_HIDDEN].Flags|= DIF_DISABLE;
#endif
}

DlgParam.DialogMode = ((SelCount == 1 && !(FileAttr & FILE_ATTRIBUTE_DIRECTORY))
? MODE_FILE
Expand Down

0 comments on commit 473f025

Please sign in to comment.