ADD: Don't show extensions for special items

This commit is contained in:
Alexander Koblov 2024-06-19 19:48:56 +03:00
commit cd3746da5e
4 changed files with 29 additions and 3 deletions

View file

@ -34,8 +34,10 @@ const
FILE_ATTRIBUTE_READONLY = $0001;
FILE_ATTRIBUTE_HIDDEN = $0002;
FILE_ATTRIBUTE_SYSTEM = $0004;
FILE_ATTRIBUTE_VOLUME = $0008;
FILE_ATTRIBUTE_DIRECTORY = $0010;
FILE_ATTRIBUTE_ARCHIVE = $0020;
FILE_ATTRIBUTE_DEVICE = $0040;
FILE_ATTRIBUTE_NORMAL = $0080;
FILE_ATTRIBUTE_TEMPORARY = $0100;
FILE_ATTRIBUTE_SPARSE_FILE = $0200;

View file

@ -125,7 +125,7 @@ implementation
uses
IniFiles, StrUtils, FtpAdv, FtpUtils, FtpConfDlg, syncobjs, LazFileUtils,
LazUTF8, DCClassesUtf8, DCConvertEncoding, SftpSend, ScpSend, FtpProxy,
FtpPropDlg;
FtpPropDlg, DCFileAttributes;
var
DefaultIniName: String;
@ -623,7 +623,7 @@ begin
begin
Connection := TConnection(ConnectionList.Objects[I - RootCount]);
StrPCopy(FindData.cFileName, CeUtf8ToUtf16(Connection.ConnectionName));
FindData.dwFileAttributes := FILE_ATTRIBUTE_NORMAL;
FindData.dwFileAttributes := FILE_ATTRIBUTE_VOLUME;
Inc(ListRec^.Index);
Result := True;
end;

View file

@ -189,6 +189,7 @@ type
// the result is false for all these functions.
// These functions should probably be moved from here and should not be methods.
function IsDirectory: Boolean;
function IsSpecial: Boolean;
function IsSysFile: Boolean;
function IsHidden: Boolean;
function IsLink: Boolean;
@ -815,6 +816,14 @@ begin
Result := False;
end;
function TFile.IsSpecial: Boolean;
begin
if fpAttributes in SupportedProperties then
Result := TFileAttributesProperty(FProperties[fpAttributes]).IsSpecial
else
Result := False;
end;
function TFile.IsLink: Boolean;
begin
if fpAttributes in SupportedProperties then
@ -901,7 +910,7 @@ procedure TFile.UpdateNameAndExtension(const FileName: string);
begin
// Cache Extension and NameNoExt.
if (FileName = '') or IsDirectory or IsLinkToDirectory
if (FileName = '') or IsDirectory or IsLinkToDirectory or IsSpecial
then
begin
// For directories there is no extension.

View file

@ -242,6 +242,8 @@ type
// Is the file a directory.
function IsDirectory: Boolean; virtual;
function IsSpecial: Boolean; virtual;
// Is this a system file.
function IsSysFile: boolean; virtual abstract;
@ -267,6 +269,8 @@ type
// Is the file a directory.
function IsDirectory: Boolean; override;
function IsSpecial: Boolean; override;
// Is this a system file.
function IsSysFile: boolean; override;
@ -883,6 +887,11 @@ begin
Result := fpS_ISDIR(FAttributes);
end;
function TFileAttributesProperty.IsSpecial: Boolean;
begin
Result := False;
end;
function TFileAttributesProperty.IsLink: Boolean;
begin
Result := fpS_ISLNK(FAttributes);
@ -901,6 +910,12 @@ begin
Result:= ((FAttributes and FILE_ATTRIBUTE_DIRECTORY) <> 0);
end;
function TNtfsFileAttributesProperty.IsSpecial: Boolean;
begin
Result:= ((FAttributes and FILE_ATTRIBUTE_DEVICE) <> 0) or
((FAttributes and FILE_ATTRIBUTE_VOLUME) <> 0);
end;
function TNtfsFileAttributesProperty.IsSysFile: boolean;
begin
Result := ((FAttributes and FILE_ATTRIBUTE_SYSTEM) <> 0) or