mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:29:26 +02:00
* Attempt to fix FileGetDateTimeInfo
(cherry picked from commit 4f029720be
)
This commit is contained in:
parent
c7924156f6
commit
a2144dfb03
@ -33,6 +33,7 @@ uses
|
||||
{$DEFINE HAS_OSCONFIG}
|
||||
{$DEFINE HAS_TEMPDIR}
|
||||
{$DEFINE HAS_LOCALTIMEZONEOFFSET}
|
||||
{$DEFINE HAS_FILEGETDATETIMEINFO}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
@ -270,6 +271,33 @@ begin
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
function FileGetDateTimeInfo(const FileName: string;
|
||||
out DateTime: TDateTimeInfoRec; FollowLink: Boolean = True): Boolean;
|
||||
var
|
||||
Data: TWin32FindDataW;
|
||||
FN: unicodestring;
|
||||
begin
|
||||
Result := False;
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
FN:=FileName;
|
||||
if Not GetFileAttributesExW(PWideChar(FileName), GetFileExInfoStandard, @Data) then
|
||||
exit;
|
||||
if ((Data.dwFileAttributes and faSymlink)=faSymlink) then
|
||||
begin
|
||||
if FollowLink then
|
||||
begin
|
||||
FN:=FollowSymlink(FileName);
|
||||
if FN='' then
|
||||
exit;
|
||||
if not GetFileAttributesExW(PWideChar(FN), GetFileExInfoStandard, @Data) then
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
DateTime.Data:=Data;
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function FileGetSymLinkTarget(const FileName: UnicodeString; out SymLinkRec: TUnicodeSymLinkRec): Boolean;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user