mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
FIX: Sort by file change time
ADD: Show file change time under Windows >= Vista
This commit is contained in:
parent
9907156255
commit
985adb14bb
4 changed files with 74 additions and 1 deletions
|
|
@ -526,6 +526,12 @@ begin
|
|||
CompressedSizeProperty.Value := mbGetCompressedFileSize(sFullPath);
|
||||
end;
|
||||
|
||||
if fpChangeTime in PropertiesToSet then
|
||||
begin
|
||||
ChangeTimeProperty := TFileChangeDateTimeProperty.Create;
|
||||
if mbGetFileChangeTime(sFullPath, FindData.ftCreationTime) then
|
||||
ChangeTimeProperty.Value := WinFileTimeToDateTime(FindData.ftCreationTime);
|
||||
end;
|
||||
{$ELSEIF DEFINED(UNIX)}
|
||||
|
||||
if ([fpAttributes,
|
||||
|
|
@ -776,6 +782,9 @@ begin
|
|||
, fpCompressedSize
|
||||
{$ENDIF}
|
||||
];
|
||||
{$IF DEFINED(MSWINDOWS)}
|
||||
if CheckWin32Version(6, 1) then Result += [fpChangeTime];
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TFileSystemFileSource.CreateListOperation(TargetPath: String): TFileSourceOperation;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,10 @@ function mbGetFileSystem(const sRootPath: String): String;
|
|||
@param(FileName The name of the file.)
|
||||
}
|
||||
function mbGetCompressedFileSize(const FileName: String): Int64;
|
||||
{en
|
||||
Retrieves the time the file was changed.
|
||||
}
|
||||
function mbGetFileChangeTime(const FileName: String; out ChangeTime: TFileTime): Boolean;
|
||||
{en
|
||||
This routine returns @true if the caller's
|
||||
process is a member of the Administrators local group.
|
||||
|
|
@ -130,7 +134,8 @@ procedure FixCommandLineToUTF8;
|
|||
implementation
|
||||
|
||||
uses
|
||||
ShellAPI, MMSystem, JwaWinNetWk, JwaWinUser, LazUTF8, DCWindows, uShlObjAdditional;
|
||||
ShellAPI, MMSystem, JwaWinNetWk, JwaWinUser, JwaNative, LazUTF8, DCWindows,
|
||||
uShlObjAdditional;
|
||||
|
||||
function GetMenuItemText(hMenu: HMENU; uItem: UINT; fByPosition: LongBool): UnicodeString;
|
||||
var
|
||||
|
|
@ -593,6 +598,31 @@ function GetTokenInformation(TokenHandle: HANDLE; TokenInformationClass: TOKEN_I
|
|||
TokenInformation: Pointer; TokenInformationLength: DWORD;
|
||||
out ReturnLength: DWORD): BOOL; stdcall; external 'advapi32' name 'GetTokenInformation';
|
||||
|
||||
function mbGetFileChangeTime(const FileName: String; out ChangeTime: TFileTime): Boolean;
|
||||
var
|
||||
Handle: System.THandle;
|
||||
lpFileInformation: TFileBasicInformation;
|
||||
GetFileInformationByHandleEx: function(hFile: THandle; FileInformationClass: DWORD;
|
||||
lpFileInformation: LPVOID; dwBufferSize: DWORD): BOOL; stdcall;
|
||||
begin
|
||||
Result:= CheckWin32Version(6, 1);
|
||||
if Result then
|
||||
begin
|
||||
Pointer(GetFileInformationByHandleEx):= GetProcAddress(GetModuleHandle(Kernel32), 'GetFileInformationByHandleEx');
|
||||
Result:= Assigned(GetFileInformationByHandleEx);
|
||||
if Result then
|
||||
begin
|
||||
Handle:= CreateFileW(PWideChar(UTF16LongName(FileName)), FILE_READ_ATTRIBUTES,
|
||||
FILE_SHARE_READ or FILE_SHARE_WRITE or FILE_SHARE_DELETE,
|
||||
nil, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
if Handle = INVALID_HANDLE_VALUE then Exit(False);
|
||||
Result:= GetFileInformationByHandleEx(Handle, 0, @lpFileInformation, SizeOf(lpFileInformation));
|
||||
CloseHandle(Handle);
|
||||
ChangeTime:= TFileTime(lpFileInformation.ChangeTime);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function IsUserAdmin: LongBool;
|
||||
var
|
||||
ReturnLength: DWORD;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ type
|
|||
procedure SetCreationTime(NewTime: TDateTime);
|
||||
function GetLastAccessTime: TDateTime;
|
||||
procedure SetLastAccessTime(NewTime: TDateTime);
|
||||
function GetChangeTime: TDateTime;
|
||||
procedure SetChangeTime(AValue: TDateTime);
|
||||
function GetIsLinkToDirectory: Boolean;
|
||||
procedure SetIsLinkToDirectory(NewValue: Boolean);
|
||||
function GetType: String;
|
||||
|
|
@ -76,6 +78,8 @@ type
|
|||
procedure SetCreationTimeProperty(NewValue: TFileCreationDateTimeProperty);
|
||||
function GetLastAccessTimeProperty: TFileLastAccessDateTimeProperty;
|
||||
procedure SetLastAccessTimeProperty(NewValue: TFileLastAccessDateTimeProperty);
|
||||
function GetChangeTimeProperty: TFileChangeDateTimeProperty;
|
||||
procedure SetChangeTimeProperty(AValue: TFileChangeDateTimeProperty);
|
||||
function GetLinkProperty: TFileLinkProperty;
|
||||
procedure SetLinkProperty(NewValue: TFileLinkProperty);
|
||||
function GetOwnerProperty: TFileOwnerProperty;
|
||||
|
|
@ -148,6 +152,7 @@ type
|
|||
property ModificationTimeProperty: TFileModificationDateTimeProperty read GetModificationTimeProperty write SetModificationTimeProperty;
|
||||
property CreationTimeProperty: TFileCreationDateTimeProperty read GetCreationTimeProperty write SetCreationTimeProperty;
|
||||
property LastAccessTimeProperty: TFileLastAccessDateTimeProperty read GetLastAccessTimeProperty write SetLastAccessTimeProperty;
|
||||
property ChangeTimeProperty: TFileChangeDateTimeProperty read GetChangeTimeProperty write SetChangeTimeProperty;
|
||||
property LinkProperty: TFileLinkProperty read GetLinkProperty write SetLinkProperty;
|
||||
property OwnerProperty: TFileOwnerProperty read GetOwnerProperty write SetOwnerProperty;
|
||||
property TypeProperty: TFileTypeProperty read GetTypeProperty write SetTypeProperty;
|
||||
|
|
@ -171,6 +176,7 @@ type
|
|||
property ModificationTime: TDateTime read GetModificationTime write SetModificationTime;
|
||||
property CreationTime: TDateTime read GetCreationTime write SetCreationTime;
|
||||
property LastAccessTime: TDateTime read GetLastAccessTime write SetLastAccessTime;
|
||||
property ChangeTime: TDateTime read GetChangeTime write SetChangeTime;
|
||||
property FileType: String read GetType write SetType;
|
||||
|
||||
// Convenience functions.
|
||||
|
|
@ -604,6 +610,30 @@ begin
|
|||
Exclude(FSupportedProperties, fpLastAccessTime);
|
||||
end;
|
||||
|
||||
function TFile.GetChangeTime: TDateTime;
|
||||
begin
|
||||
Result := TFileChangeDateTimeProperty(FProperties[fpChangeTime]).Value;
|
||||
end;
|
||||
|
||||
procedure TFile.SetChangeTime(AValue: TDateTime);
|
||||
begin
|
||||
TFileChangeDateTimeProperty(FProperties[fpChangeTime]).Value := AValue;
|
||||
end;
|
||||
|
||||
function TFile.GetChangeTimeProperty: TFileChangeDateTimeProperty;
|
||||
begin
|
||||
Result := TFileChangeDateTimeProperty(FProperties[fpChangeTime]);
|
||||
end;
|
||||
|
||||
procedure TFile.SetChangeTimeProperty(AValue: TFileChangeDateTimeProperty);
|
||||
begin
|
||||
FProperties[fpChangeTime] := AValue;
|
||||
if Assigned(AValue) then
|
||||
Include(FSupportedProperties, fpChangeTime)
|
||||
else
|
||||
Exclude(FSupportedProperties, fpChangeTime);
|
||||
end;
|
||||
|
||||
function TFile.GetLinkProperty: TFileLinkProperty;
|
||||
begin
|
||||
Result := TFileLinkProperty(FProperties[fpLink]);
|
||||
|
|
|
|||
|
|
@ -673,6 +673,10 @@ begin
|
|||
Result := ICompareByDate(File1.LastAccessTime,
|
||||
File2.LastAccessTime,
|
||||
bNegative);
|
||||
fsfChangeTime:
|
||||
Result := ICompareByDate(File1.ChangeTime,
|
||||
File2.ChangeTime,
|
||||
bNegative);
|
||||
fsfLinkTo:
|
||||
begin
|
||||
Result := mbCompareText(File1.LinkProperty.LinkTo,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue