mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:29:26 +02:00
+ make use of the fputimensat syscall on linux to enable always times beyond 32 bit
git-svn-id: trunk@48471 -
This commit is contained in:
parent
0c77536f11
commit
e6f575d43c
@ -56,7 +56,8 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$if defined(LINUX)}
|
{$if defined(LINUX)}
|
||||||
{$DEFINE HAS_STATX}
|
{$DEFINE USE_STATX}
|
||||||
|
{$DEFINE USE_UTIMENSAT}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{ Include platform independent interface part }
|
{ Include platform independent interface part }
|
||||||
@ -556,20 +557,20 @@ Function FileAge (Const FileName : RawByteString): Int64;
|
|||||||
Var
|
Var
|
||||||
Info : Stat;
|
Info : Stat;
|
||||||
SystemFileName: RawByteString;
|
SystemFileName: RawByteString;
|
||||||
{$ifdef HAS_STATX}
|
{$ifdef USE_STATX}
|
||||||
Infox : Statx;
|
Infox : Statx;
|
||||||
{$endif HAS_STATX}
|
{$endif USE_STATX}
|
||||||
begin
|
begin
|
||||||
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
||||||
|
|
||||||
{$ifdef HAS_STATX}
|
{$ifdef USE_STATX}
|
||||||
{ first try statx }
|
{ first try statx }
|
||||||
if (Fpstatx(0,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
|
if (Fpstatx(0,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
|
||||||
begin
|
begin
|
||||||
Result:=Infox.stx_mtime.tv_sec;
|
Result:=Infox.stx_mtime.tv_sec;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
{$endif HAS_STATX}
|
{$endif USE_STATX}
|
||||||
|
|
||||||
If (fpstat(pchar(SystemFileName),Info)<0) or fpS_ISDIR(info.st_mode) then
|
If (fpstat(pchar(SystemFileName),Info)<0) or fpS_ISDIR(info.st_mode) then
|
||||||
exit(-1)
|
exit(-1)
|
||||||
@ -1086,14 +1087,27 @@ end;
|
|||||||
Function FileSetDate (Const FileName : RawByteString; Age : Int64) : Longint;
|
Function FileSetDate (Const FileName : RawByteString; Age : Int64) : Longint;
|
||||||
var
|
var
|
||||||
SystemFileName: RawByteString;
|
SystemFileName: RawByteString;
|
||||||
|
{$ifdef USE_UTIMENSAT}
|
||||||
|
times : tkernel_timespecs;
|
||||||
|
{$else USE_UTIMENSAT}
|
||||||
t: TUTimBuf;
|
t: TUTimBuf;
|
||||||
|
{$endif USE_UTIMENSAT}
|
||||||
begin
|
begin
|
||||||
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
||||||
Result:=0;
|
Result:=0;
|
||||||
|
{$ifdef USE_UTIMENSAT}
|
||||||
|
times[0].tv_sec:=Age;
|
||||||
|
times[0].tv_nsec:=0;
|
||||||
|
times[1].tv_sec:=Age;
|
||||||
|
times[1].tv_nsec:=0;
|
||||||
|
if fputimensat(AT_FDCWD,PChar(SystemFileName),times,0) = -1 then
|
||||||
|
Result:=fpgeterrno;
|
||||||
|
{$else USE_UTIMENSAT}
|
||||||
t.actime:= Age;
|
t.actime:= Age;
|
||||||
t.modtime:=Age;
|
t.modtime:=Age;
|
||||||
if fputime(PChar(SystemFileName), @t) = -1 then
|
if fputime(PChar(SystemFileName), @t) = -1 then
|
||||||
Result:=fpgeterrno;
|
Result:=fpgeterrno;
|
||||||
|
{$endif USE_UTIMENSAT}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user