mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 19:10:14 +02:00
* DOS<->Win filetime conversion was fixed.
* FileExists fix from Win32 was applied. git-svn-id: trunk@1405 -
This commit is contained in:
parent
396b5524ee
commit
3239011837
@ -33,6 +33,9 @@ Type
|
|||||||
|
|
||||||
{$i dosh.inc}
|
{$i dosh.inc}
|
||||||
|
|
||||||
|
Function WinToDosTime (Const Wtime : TFileTime; var DTime:longint):longbool;
|
||||||
|
Function DosToWinTime (DTime:longint; var Wtime : TFileTime):longbool;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$DEFINE HAS_GETMSCOUNT}
|
{$DEFINE HAS_GETMSCOUNT}
|
||||||
@ -73,16 +76,50 @@ begin
|
|||||||
WinToDosAttr:=Attr;
|
WinToDosAttr:=Attr;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
Longrec=packed record
|
||||||
|
lo,hi : word;
|
||||||
|
end;
|
||||||
|
|
||||||
Function DosToWinTime (DTime:longint;Var Wtime : TFileTime):longbool;
|
Function DosToWinTime (DTime:longint; var Wtime : TFileTime):longbool;
|
||||||
|
var
|
||||||
|
FatDate, FatTime: WORD;
|
||||||
|
lft: TFileTime;
|
||||||
|
st: SYSTEMTIME;
|
||||||
begin
|
begin
|
||||||
DosToWinTime:=False; //!!! fixme
|
FatDate:=Longrec(Dtime).Hi;
|
||||||
|
FatTime:=Longrec(Dtime).Lo;
|
||||||
|
with st do
|
||||||
|
begin
|
||||||
|
wDay:=FatDate and $1F;
|
||||||
|
wMonth:=(FatDate shr 5) and $F;
|
||||||
|
wYear:=(FatDate shr 9) + 1980;
|
||||||
|
wSecond:=(FatTime and $1F)*2;
|
||||||
|
wMinute:=(FatTime shr 5) and $1F;
|
||||||
|
wHour:=FatTime shr 11;
|
||||||
|
wMilliseconds:=0;
|
||||||
|
wDayOfWeek:=0;
|
||||||
|
end;
|
||||||
|
DosToWinTime:=SystemTimeToFileTime(@st, @lft) and LocalFileTimeToFileTime(@lft, @Wtime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function WinToDosTime (Const Wtime : TFileTime;var DTime:longint):longbool;
|
Function WinToDosTime (Const Wtime : TFileTime; var DTime:longint):longbool;
|
||||||
|
var
|
||||||
|
FatDate, FatTime: WORD;
|
||||||
|
lft: TFileTime;
|
||||||
|
st: SYSTEMTIME;
|
||||||
|
res: longbool;
|
||||||
begin
|
begin
|
||||||
WinToDosTime:=False; //!!! fixme
|
res:=FileTimeToLocalFileTime(@WTime, @lft) and FileTimeToSystemTime(@lft, @st);
|
||||||
|
if res then
|
||||||
|
begin
|
||||||
|
FatDate:=st.wDay or (st.wMonth shl 5) or ((st.wYear - 1980) shl 9);
|
||||||
|
FatTime:=(st.wSecond div 2) or (st.wMinute shl 5) or (st.wHour shl 11);
|
||||||
|
Longrec(Dtime).Hi:=FatDate;
|
||||||
|
Longrec(Dtime).Lo:=FatTime;
|
||||||
|
end;
|
||||||
|
WinToDosTime:=res;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -481,17 +518,17 @@ end;
|
|||||||
|
|
||||||
function envcount : longint;
|
function envcount : longint;
|
||||||
begin
|
begin
|
||||||
envcount:=0; //!!! fixme
|
envcount:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function EnvStr (Index: longint): string;
|
Function EnvStr (Index: longint): string;
|
||||||
begin
|
begin
|
||||||
EnvStr:=''; //!!! fixme
|
EnvStr:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetEnv(envvar: string): string;
|
Function GetEnv(envvar: string): string;
|
||||||
begin
|
begin
|
||||||
GetEnv:=''; //!!! fixme
|
GetEnv:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -216,13 +216,13 @@ end;
|
|||||||
|
|
||||||
Function DosToWinTime (DTime:longint; out Wtime : TFileTime):longbool;
|
Function DosToWinTime (DTime:longint; out Wtime : TFileTime):longbool;
|
||||||
begin
|
begin
|
||||||
DosToWinTime:=False; //!!! fixme
|
DosToWinTime:=dos.DosToWinTime(DTime, Wtime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function WinToDosTime (Const Wtime : TFileTime; out DTime:longint):longbool;
|
Function WinToDosTime (Const Wtime : TFileTime; out DTime:longint):longbool;
|
||||||
begin
|
begin
|
||||||
WinToDosTime:=False; //!!! fixme
|
WinToDosTime:=dos.WinToDosTime(Wtime, DTime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -248,29 +248,23 @@ end;
|
|||||||
|
|
||||||
Function FileExists (Const FileName : String) : Boolean;
|
Function FileExists (Const FileName : String) : Boolean;
|
||||||
var
|
var
|
||||||
Handle: THandle;
|
Attr:Dword;
|
||||||
FindData: TWin32FindData;
|
|
||||||
fn: PWideChar;
|
|
||||||
begin
|
begin
|
||||||
fn:=StringToPWideChar(FileName);
|
Attr:=FileGetAttr(FileName);
|
||||||
Handle := FindFirstFile(PWideChar(widestring(FileName)), FindData);
|
if Attr <> $ffffffff then
|
||||||
FreeMem(fn);
|
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0
|
||||||
Result:=Handle <> INVALID_HANDLE_VALUE;
|
else
|
||||||
If Result then
|
Result:=False;
|
||||||
Windows.FindClose(Handle);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function DirectoryExists (Const Directory : String) : Boolean;
|
Function DirectoryExists (Const Directory : String) : Boolean;
|
||||||
var
|
var
|
||||||
Attr:Dword;
|
Attr:Dword;
|
||||||
fn: PWideChar;
|
|
||||||
begin
|
begin
|
||||||
fn:=StringToPWideChar(Directory);
|
Attr:=FileGetAttr(Directory);
|
||||||
Attr:=GetFileAttributes(fn);
|
|
||||||
FreeMem(fn);
|
|
||||||
if Attr <> $ffffffff then
|
if Attr <> $ffffffff then
|
||||||
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) > 0
|
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) <> 0
|
||||||
else
|
else
|
||||||
Result:=False;
|
Result:=False;
|
||||||
end;
|
end;
|
||||||
@ -339,7 +333,7 @@ Var
|
|||||||
FT : TFileTime;
|
FT : TFileTime;
|
||||||
begin
|
begin
|
||||||
If GetFileTime(Handle,nil,nil,@ft) and
|
If GetFileTime(Handle,nil,nil,@ft) and
|
||||||
WinToDosTime(FT,Result) then
|
WinToDosTime(FT, Result) then
|
||||||
exit;
|
exit;
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
end;
|
end;
|
||||||
@ -350,8 +344,7 @@ Var
|
|||||||
FT: TFileTime;
|
FT: TFileTime;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
if DosToWinTime(Age,FT) and
|
if DosToWinTime(Age, FT) and SetFileTime(Handle, FT, FT, FT) then
|
||||||
SetFileTime(Handle, ft, ft, FT) then
|
|
||||||
Exit;
|
Exit;
|
||||||
Result := GetLastError;
|
Result := GetLastError;
|
||||||
end;
|
end;
|
||||||
@ -651,17 +644,17 @@ end;
|
|||||||
|
|
||||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||||
begin
|
begin
|
||||||
Result := ''; //!!! fixme
|
Result := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetEnvironmentVariableCount : Integer;
|
Function GetEnvironmentVariableCount : Integer;
|
||||||
begin
|
begin
|
||||||
Result := 0; //!!! fixme
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetEnvironmentString(Index : Integer) : String;
|
Function GetEnvironmentString(Index : Integer) : String;
|
||||||
begin
|
begin
|
||||||
Result := ''; //!!! fixme
|
Result := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user