mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-25 18:01:53 +02:00
+ Moved getlocaltime to system-dependent files
This commit is contained in:
parent
a7bb45265d
commit
f6908c234f
@ -331,10 +331,30 @@ begin
|
|||||||
result := DOS.FSearch(Name, DirList);
|
result := DOS.FSearch(Name, DirList);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure GetLocalTime(var SystemTime: TSystemTime);
|
||||||
|
|
||||||
|
var Regs: Registers;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Regs.ah := $2C;
|
||||||
|
RealIntr($21, Regs);
|
||||||
|
SystemTime.Hour := Regs.Ch;
|
||||||
|
SystemTime.Minute := Regs.Cl;
|
||||||
|
SystemTime.Second := Regs.Dh;
|
||||||
|
SystemTime.MilliSecond := Regs.Dl;
|
||||||
|
Regs.ah := $2A;
|
||||||
|
RealIntr($21, Regs);
|
||||||
|
SystemTime.Year := Regs.Cx;
|
||||||
|
SystemTime.Month := Regs.Dh;
|
||||||
|
SystemTime.Day := Regs.Dl;
|
||||||
|
end ;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1999-02-09 17:16:59 florian
|
Revision 1.4 1999-02-24 15:57:28 michael
|
||||||
|
+ Moved getlocaltime to system-dependent files
|
||||||
|
|
||||||
|
Revision 1.3 1999/02/09 17:16:59 florian
|
||||||
+ typinfo is now also in the makefile for go32v2
|
+ typinfo is now also in the makefile for go32v2
|
||||||
+ sysutils.filetruncate for go32v2
|
+ sysutils.filetruncate for go32v2
|
||||||
|
|
||||||
|
|||||||
@ -233,10 +233,21 @@ begin
|
|||||||
FileSearch:=Linux.FSearch(Name,Dirlist);
|
FileSearch:=Linux.FSearch(Name,Dirlist);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure GetLocalTime(var SystemTime: TSystemTime);
|
||||||
|
|
||||||
|
begin
|
||||||
|
linux.GetTime(SystemTime.Hour, SystemTime.Minute, SystemTime.Second);
|
||||||
|
linux.GetDate(SystemTime.Year, SystemTime.Month, SystemTime.Day);
|
||||||
|
SystemTime.MilliSecond := 0;
|
||||||
|
end ;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.6 1999-02-04 21:43:08 michael
|
Revision 1.7 1999-02-24 15:57:29 michael
|
||||||
|
+ Moved getlocaltime to system-dependent files
|
||||||
|
|
||||||
|
Revision 1.6 1999/02/04 21:43:08 michael
|
||||||
FileCreate must truncate the file
|
FileCreate must truncate the file
|
||||||
|
|
||||||
Revision 1.5 1999/02/02 21:20:34 michael
|
Revision 1.5 1999/02/02 21:20:34 michael
|
||||||
|
|||||||
@ -91,6 +91,23 @@ begin
|
|||||||
Result:=SetEndOfFile(handle);
|
Result:=SetEndOfFile(handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function DosToWinTime (DTime:longint;Var Wtime : TFileTime):longbool;
|
||||||
|
var
|
||||||
|
lft : TFileTime;
|
||||||
|
begin
|
||||||
|
DosToWinTime:=DosDateTimeToFileTime(longrec(dtime).hi,longrec(dtime).lo,@lft) and
|
||||||
|
LocalFileTimeToFileTime(lft,@Wtime);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function WinToDosTime (Var Wtime : TFileTime;var DTime:longint):longbool;
|
||||||
|
var
|
||||||
|
lft : FileTime;
|
||||||
|
begin
|
||||||
|
WinToDosTime:=FileTimeToLocalFileTime(WTime,@lft) and
|
||||||
|
FileTimeToDosDateTime(lft,@Longrec(Dtime).Hi,@LongRec(DTIME).lo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileAge (Const FileName : String): Longint;
|
Function FileAge (Const FileName : String): Longint;
|
||||||
|
|
||||||
@ -101,18 +118,12 @@ var
|
|||||||
Fn : String;
|
Fn : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FN:=FN+#0;
|
Handle := FindFirstFile(Pchar(FileName), @FindData);
|
||||||
Handle := FindFirstFile(@FN[1], @FindData);
|
|
||||||
if Handle <> INVALID_HANDLE_VALUE then
|
if Handle <> INVALID_HANDLE_VALUE then
|
||||||
begin
|
begin
|
||||||
Windows.FindClose(Handle);
|
Windows.FindClose(Handle);
|
||||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
|
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
|
||||||
begin
|
If WinToDosTime(FindData.ftLastWriteTime,Result) then exit;
|
||||||
{
|
|
||||||
FileTimeToLocalFileTime(FindData.ftLastWriteTime, @LocalFileTime);
|
|
||||||
if FileTimeToDosDateTime(LocalFileTime, LongRec(Result).Hi,
|
|
||||||
LongRec(Result).Lo) then Exit;
|
|
||||||
} end;
|
|
||||||
end;
|
end;
|
||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
@ -120,84 +131,178 @@ end;
|
|||||||
|
|
||||||
Function FileExists (Const FileName : String) : Boolean;
|
Function FileExists (Const FileName : String) : Boolean;
|
||||||
|
|
||||||
|
var
|
||||||
|
Handle: THandle;
|
||||||
|
FindData: TWin32FindData;
|
||||||
|
P : Pchar;
|
||||||
begin
|
begin
|
||||||
Result := FileAge(FileName) <> -1;
|
P:=Pchar(Filename);
|
||||||
|
Handle := FindFirstFile(Pchar(FileName), @FindData);
|
||||||
|
Result:=Handle <> INVALID_HANDLE_VALUE;
|
||||||
|
If Result then
|
||||||
|
Windows.FindClose(Handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function FindMatch(var f: TSearchRec) : Longint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{ Find file with correct attribute }
|
||||||
|
While (F.FindData.dwFileAttributes and F.ExcludeAttr)<>0 do
|
||||||
|
begin
|
||||||
|
if not FindNextFile (F.FindHandle,@F.FindData) then
|
||||||
|
begin
|
||||||
|
Result:=GetLastError;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{ Convert some attributes back }
|
||||||
|
WinToDosTime(F.FindData.ftLastWriteTime,F.Time);
|
||||||
|
f.size:=F.FindData.NFileSizeLow;
|
||||||
|
f.attr:=F.FindData.dwFileAttributes;
|
||||||
|
f.Name:=StrPas(@F.FindData.cFileName);
|
||||||
|
end;
|
||||||
|
|
||||||
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
|
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
Rslt.Name:=Path;
|
||||||
|
Rslt.Attr:=attr;
|
||||||
|
Rslt.ExcludeAttr:=(not Attr) and ($1e);
|
||||||
|
{ $1e = faHidden or faSysFile or faVolumeID or faDirectory }
|
||||||
|
{ FindFirstFile is a Win32 Call }
|
||||||
|
Rslt.FindHandle:=FindFirstFile (PChar(Path),@Rslt.FindData);
|
||||||
|
If Rslt.FindHandle=Invalid_Handle_value then
|
||||||
|
begin
|
||||||
|
Result:=GetLastError;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
{ Find file with correct attribute }
|
||||||
|
Result:=FindMatch(Rslt);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
Function FindNext (Var Rslt : TSearchRec) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
if FindNextFile(Rslt.FindHandle, @Rslt.FindData) then
|
||||||
|
Result := FindMatch(Rslt)
|
||||||
|
else
|
||||||
|
Result := GetLastError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure FindClose (Var F : TSearchrec);
|
Procedure FindClose (Var F : TSearchrec);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
if F.FindHandle <> INVALID_HANDLE_VALUE then
|
||||||
|
Windows.FindClose(F.FindHandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function FileGetDate (Handle : Longint) : Longint;
|
Function FileGetDate (Handle : Longint) : Longint;
|
||||||
|
|
||||||
|
Var FT : TFileTime;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
If GetFileTime(Handle,nil,nil,@ft) and
|
||||||
|
WinToDosTime(FT,Result) then exit;
|
||||||
|
Result:=-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSetDate (Handle,Age : Longint) : Longint;
|
Function FileSetDate (Handle,Age : Longint) : Longint;
|
||||||
|
|
||||||
|
Var FT: TFileTime;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
Result := 0;
|
||||||
|
if DosToWinTime(Age,FT) and
|
||||||
|
SetFileTime(Handle, ft, ft, FT) then Exit;
|
||||||
|
Result := GetLastError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileGetAttr (Const FileName : String) : Longint;
|
Function FileGetAttr (Const FileName : String) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
Result:=GetFileAttributes(PChar(FileName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
if not SetFileAttributes(PChar(FileName), Attr) then
|
||||||
|
Result := GetLastError
|
||||||
|
else
|
||||||
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function DeleteFile (Const FileName : String) : Boolean;
|
Function DeleteFile (Const FileName : String) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
DeleteFile:=Windows.DeleteFile(Pchar(FileName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function RenameFile (Const OldName, NewName : String) : Boolean;
|
Function RenameFile (Const OldName, NewName : String) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
Result := MoveFile(PChar(OldName), PChar(NewName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function FileSearch (Const Name, DirList : String) : String;
|
Function FileSearch (Const Name, DirList : String) : String;
|
||||||
|
|
||||||
|
Var I : longint;
|
||||||
|
Temp : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! Needs implementing
|
Result:='';
|
||||||
|
temp:=Dirlist;
|
||||||
|
repeat
|
||||||
|
I:=pos(';',Temp);
|
||||||
|
If I<>0 then
|
||||||
|
begin
|
||||||
|
Result:=Copy (Temp,1,i-1);
|
||||||
|
system.Delete(Temp,1,I);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Result:=Temp;
|
||||||
|
Temp:='';
|
||||||
|
end;
|
||||||
|
If result[length(result)]<>'\' then
|
||||||
|
Result:=Result+'\';
|
||||||
|
Result:=Result+name;
|
||||||
|
If not FileExists(Result) Then
|
||||||
|
Result:='';
|
||||||
|
until (length(temp)=0) or (length(result)<>0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure GetLocalTime(var ST: TSystemTime);
|
||||||
|
|
||||||
|
Var Syst:Systemtime;
|
||||||
|
|
||||||
|
begin
|
||||||
|
windows.Getlocaltime(@syst);
|
||||||
|
st.year:=syst.wYear;
|
||||||
|
st.month:=syst.wMonth;
|
||||||
|
st.day:=syst.wDay;
|
||||||
|
st.hour:=syst.wHour;
|
||||||
|
st.minute:=syst.wMinute;
|
||||||
|
st.second:=syst.wSecond;
|
||||||
|
st.millisecond:=syst.wMilliSeconds;
|
||||||
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1999-02-09 12:01:03 michael
|
Revision 1.4 1999-02-24 15:57:30 michael
|
||||||
|
+ Moved getlocaltime to system-dependent files
|
||||||
|
|
||||||
|
Revision 1.3 1999/02/09 12:01:03 michael
|
||||||
+ Implemented filetruncate
|
+ Implemented filetruncate
|
||||||
|
|
||||||
Revision 1.2 1999/02/03 11:41:30 michael
|
Revision 1.2 1999/02/03 11:41:30 michael
|
||||||
@ -206,4 +311,4 @@ end;
|
|||||||
Revision 1.1 1998/10/11 12:21:01 michael
|
Revision 1.1 1998/10/11 12:21:01 michael
|
||||||
Added file calls. Implemented for linux only
|
Added file calls. Implemented for linux only
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user