mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 10:29:18 +02:00
* more 64 bit clean up
git-svn-id: trunk@3224 -
This commit is contained in:
parent
2a710b5fd4
commit
1db5db975e
@ -19,22 +19,22 @@ Const
|
||||
Max_Path = 260;
|
||||
|
||||
Type
|
||||
PWin32FileTime = ^TWin32FileTime;
|
||||
TWin32FileTime = record
|
||||
PWinFileTime = ^TWinFileTime;
|
||||
TWinFileTime = record
|
||||
dwLowDateTime,
|
||||
dwHighDateTime : DWORD;
|
||||
end;
|
||||
|
||||
PWin32FindData = ^TWin32FindData;
|
||||
TWin32FindData = record
|
||||
dwFileAttributes: Cardinal;
|
||||
ftCreationTime: TWin32FileTime;
|
||||
ftLastAccessTime: TWin32FileTime;
|
||||
ftLastWriteTime: TWin32FileTime;
|
||||
nFileSizeHigh: Cardinal;
|
||||
nFileSizeLow: Cardinal;
|
||||
dwReserved0: Cardinal;
|
||||
dwReserved1: Cardinal;
|
||||
PWinFindData = ^TWinFindData;
|
||||
TWinFindData = record
|
||||
dwFileAttributes: DWORD;
|
||||
ftCreationTime: TWinFileTime;
|
||||
ftLastAccessTime: TWinFileTime;
|
||||
ftLastWriteTime: TWinFileTime;
|
||||
nFileSizeHigh: DWORD;
|
||||
nFileSizeLow: DWORD;
|
||||
dwReserved0: DWORD;
|
||||
dwReserved1: DWORD;
|
||||
cFileName: array[0..MAX_PATH-1] of Char;
|
||||
cAlternateFileName: array[0..13] of Char;
|
||||
// The structure should be 320 bytes long...
|
||||
@ -43,7 +43,7 @@ Type
|
||||
|
||||
Searchrec = Packed Record
|
||||
FindHandle : THandle;
|
||||
W32FindData : TWin32FindData;
|
||||
WinFindData : TWinFindData;
|
||||
ExcludeAttr : longint;
|
||||
time : longint;
|
||||
size : longint;
|
||||
@ -77,7 +77,7 @@ uses
|
||||
{$I dos.inc}
|
||||
|
||||
const
|
||||
INVALID_HANDLE_VALUE = longint($ffffffff);
|
||||
INVALID_HANDLE_VALUE = THandle(-1);
|
||||
|
||||
VER_PLATFORM_WIN32s = 0;
|
||||
VER_PLATFORM_WIN32_WINDOWS = 1;
|
||||
@ -103,13 +103,13 @@ var
|
||||
|
||||
function GetLastError : DWORD;
|
||||
stdcall; external 'kernel32' name 'GetLastError';
|
||||
function FileTimeToDosDateTime(const ft :TWin32FileTime;var data,time : word) : longbool;
|
||||
function FileTimeToDosDateTime(const ft :TWinFileTime;var data,time : word) : longbool;
|
||||
stdcall; external 'kernel32' name 'FileTimeToDosDateTime';
|
||||
function DosDateTimeToFileTime(date,time : word;var ft :TWin32FileTime) : longbool;
|
||||
function DosDateTimeToFileTime(date,time : word;var ft :TWinFileTime) : longbool;
|
||||
stdcall; external 'kernel32' name 'DosDateTimeToFileTime';
|
||||
function FileTimeToLocalFileTime(const ft : TWin32FileTime;var lft : TWin32FileTime) : longbool;
|
||||
function FileTimeToLocalFileTime(const ft : TWinFileTime;var lft : TWinFileTime) : longbool;
|
||||
stdcall; external 'kernel32' name 'FileTimeToLocalFileTime';
|
||||
function LocalFileTimeToFileTime(const lft : TWin32FileTime;var ft : TWin32FileTime) : longbool;
|
||||
function LocalFileTimeToFileTime(const lft : TWinFileTime;var ft : TWinFileTime) : longbool;
|
||||
stdcall; external 'kernel32' name 'LocalFileTimeToFileTime';
|
||||
function GetTickCount : longint;
|
||||
stdcall;external 'kernel32' name 'GetTickCount';
|
||||
@ -147,18 +147,18 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function DosToWinTime (DTime:longint;Var Wtime : TWin32FileTime):longbool;
|
||||
Function DosToWinTime (DTime:longint;Var Wtime : TWinFileTime):longbool;
|
||||
var
|
||||
lft : TWin32FileTime;
|
||||
lft : TWinFileTime;
|
||||
begin
|
||||
DosToWinTime:=DosDateTimeToFileTime(longrec(dtime).hi,longrec(dtime).lo,lft) and
|
||||
LocalFileTimeToFileTime(lft,Wtime);
|
||||
end;
|
||||
|
||||
|
||||
Function WinToDosTime (Const Wtime : TWin32FileTime;var DTime:longint):longbool;
|
||||
Function WinToDosTime (Const Wtime : TWinFileTime;var DTime:longint):longbool;
|
||||
var
|
||||
lft : TWin32FileTime;
|
||||
lft : TWinFileTime;
|
||||
begin
|
||||
WinToDosTime:=FileTimeToLocalFileTime(WTime,lft) and
|
||||
FileTimeToDosDateTime(lft,longrec(dtime).hi,longrec(dtime).lo);
|
||||
@ -340,7 +340,7 @@ function diskfree(drive : byte) : int64;
|
||||
var
|
||||
disk : array[1..4] of char;
|
||||
secs,bytes,
|
||||
free,total : longword;
|
||||
free,total : DWORD;
|
||||
qwtotal,qwfree,qwcaller : int64;
|
||||
|
||||
|
||||
@ -378,7 +378,7 @@ function disksize(drive : byte) : int64;
|
||||
var
|
||||
disk : array[1..4] of char;
|
||||
secs,bytes,
|
||||
free,total : longword;
|
||||
free,total : DWORD;
|
||||
qwtotal,qwfree,qwcaller : int64;
|
||||
|
||||
begin
|
||||
@ -417,9 +417,9 @@ end;
|
||||
|
||||
{ Needed kernel calls }
|
||||
|
||||
function FindFirstFile (lpFileName: PChar; var lpFindFileData: TWIN32FindData): THandle;
|
||||
function FindFirstFile (lpFileName: PChar; var lpFindFileData: TWinFindData): THandle;
|
||||
stdcall; external 'kernel32' name 'FindFirstFileA';
|
||||
function FindNextFile (hFindFile: THandle; var lpFindFileData: TWIN32FindData): LongBool;
|
||||
function FindNextFile (hFindFile: THandle; var lpFindFileData: TWinFindData): LongBool;
|
||||
stdcall; external 'kernel32' name 'FindNextFileA';
|
||||
function FindCloseFile (hFindFile: THandle): LongBool;
|
||||
stdcall; external 'kernel32' name 'FindClose';
|
||||
@ -444,9 +444,9 @@ end;
|
||||
procedure FindMatch(var f:searchrec);
|
||||
begin
|
||||
{ Find file with correct attribute }
|
||||
While (F.W32FindData.dwFileAttributes and cardinal(F.ExcludeAttr))<>0 do
|
||||
While (F.WinFindData.dwFileAttributes and DWORD(F.ExcludeAttr))<>0 do
|
||||
begin
|
||||
if not FindNextFile (F.FindHandle,F.W32FindData) then
|
||||
if not FindNextFile (F.FindHandle,F.WinFindData) then
|
||||
begin
|
||||
DosError:=Last2DosError(GetLastError);
|
||||
if DosError=2 then
|
||||
@ -456,10 +456,10 @@ begin
|
||||
end;
|
||||
|
||||
{ Convert some attributes back }
|
||||
f.size:=F.W32FindData.NFileSizeLow;
|
||||
f.attr:=WinToDosAttr(F.W32FindData.dwFileAttributes);
|
||||
WinToDosTime(F.W32FindData.ftLastWriteTime,f.Time);
|
||||
f.Name:=StrPas(@F.W32FindData.cFileName);
|
||||
f.size:=F.WinFindData.NFileSizeLow;
|
||||
f.attr:=WinToDosAttr(F.WinFindData.dwFileAttributes);
|
||||
WinToDosTime(F.WinFindData.ftLastWriteTime,f.Time);
|
||||
f.Name:=StrPas(@F.WinFindData.cFileName);
|
||||
end;
|
||||
|
||||
|
||||
@ -474,10 +474,10 @@ begin
|
||||
StringToPchar(f.name);
|
||||
|
||||
{ FindFirstFile is a Win32 Call }
|
||||
F.W32FindData.dwFileAttributes:=DosToWinAttr(f.attr);
|
||||
F.FindHandle:=FindFirstFile (pchar(@f.Name),F.W32FindData);
|
||||
F.WinFindData.dwFileAttributes:=DosToWinAttr(f.attr);
|
||||
F.FindHandle:=FindFirstFile (pchar(@f.Name),F.WinFindData);
|
||||
|
||||
If longint(F.FindHandle)=Invalid_Handle_value then
|
||||
If F.FindHandle=Invalid_Handle_value then
|
||||
begin
|
||||
DosError:=Last2DosError(GetLastError);
|
||||
if DosError=2 then
|
||||
@ -493,7 +493,7 @@ procedure findnext(var f : searchRec);
|
||||
begin
|
||||
{ no error }
|
||||
doserror:=0;
|
||||
if not FindNextFile (F.FindHandle,F.W32FindData) then
|
||||
if not FindNextFile (F.FindHandle,F.WinFindData) then
|
||||
begin
|
||||
DosError:=Last2DosError(GetLastError);
|
||||
if DosError=2 then
|
||||
@ -507,7 +507,7 @@ end;
|
||||
|
||||
Procedure FindClose(Var f: SearchRec);
|
||||
begin
|
||||
If longint(F.FindHandle)<>Invalid_Handle_value then
|
||||
If F.FindHandle<>Invalid_Handle_value then
|
||||
FindCloseFile(F.FindHandle);
|
||||
end;
|
||||
|
||||
@ -516,9 +516,9 @@ end;
|
||||
--- File ---
|
||||
******************************************************************************}
|
||||
|
||||
function GeTWin32FileTime(h : longint;creation,lastaccess,lastwrite : PWin32FileTime) : longbool;
|
||||
function GetWinFileTime(h : longint;creation,lastaccess,lastwrite : PWinFileTime) : longbool;
|
||||
stdcall; external 'kernel32' name 'GetFileTime';
|
||||
function SeTWin32FileTime(h : longint;creation,lastaccess,lastwrite : PWin32FileTime) : longbool;
|
||||
function SetWinFileTime(h : longint;creation,lastaccess,lastwrite : PWinFileTime) : longbool;
|
||||
stdcall; external 'kernel32' name 'SetFileTime';
|
||||
function SetFileAttributes(lpFileName : pchar;dwFileAttributes : longint) : longbool;
|
||||
stdcall; external 'kernel32' name 'SetFileAttributesA';
|
||||
@ -530,7 +530,6 @@ end;
|
||||
|
||||
function GetFullPathName(lpFileName: PChar; nBufferLength: Longint; lpBuffer: PChar; var lpFilePart : PChar):DWORD;
|
||||
stdcall; external 'kernel32' name 'GetFullPathNameA';
|
||||
|
||||
function GetShortPathName(lpszLongPath:pchar; lpszShortPath:pchar; cchBuffer:DWORD):DWORD;
|
||||
stdcall; external 'kernel32' name 'GetShortPathNameA';
|
||||
|
||||
@ -582,14 +581,13 @@ begin
|
||||
findclose(s);
|
||||
end;
|
||||
|
||||
{ </immobilizer> }
|
||||
|
||||
procedure getftime(var f;var time : longint);
|
||||
var
|
||||
ft : TWin32FileTime;
|
||||
ft : TWinFileTime;
|
||||
begin
|
||||
doserror:=0;
|
||||
if GeTWin32FileTime(filerec(f).Handle,nil,nil,@ft) and
|
||||
if GetWinFileTime(filerec(f).Handle,nil,nil,@ft) and
|
||||
WinToDosTime(ft,time) then
|
||||
exit
|
||||
else
|
||||
@ -602,11 +600,11 @@ end;
|
||||
|
||||
procedure setftime(var f;time : longint);
|
||||
var
|
||||
ft : TWin32FileTime;
|
||||
ft : TWinFileTime;
|
||||
begin
|
||||
doserror:=0;
|
||||
if DosToWinTime(time,ft) and
|
||||
SeTWin32FileTime(filerec(f).Handle,nil,nil,@ft) then
|
||||
SetWinFileTime(filerec(f).Handle,nil,nil,@ft) then
|
||||
exit
|
||||
else
|
||||
DosError:=Last2DosError(GetLastError);
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
const
|
||||
{ constants for GetStdHandle }
|
||||
STD_INPUT_HANDLE = dword($fffffff6);
|
||||
STD_OUTPUT_HANDLE = dword($fffffff5);
|
||||
STD_ERROR_HANDLE = dword($fffffff4);
|
||||
INVALID_HANDLE_VALUE = dword($ffffffff);
|
||||
STD_INPUT_HANDLE = dword(-10);
|
||||
STD_OUTPUT_HANDLE = dword(-11);
|
||||
STD_ERROR_HANDLE = dword(-12);
|
||||
INVALID_HANDLE_VALUE = THandle(-1);
|
||||
|
||||
IGNORE = 0; { Ignore signal }
|
||||
INFINITE = longint($FFFFFFFF); { Infinite timeout }
|
||||
|
Loading…
Reference in New Issue
Block a user