mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 02:07:53 +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}
|
||||
|
||||
Function WinToDosTime (Const Wtime : TFileTime; var DTime:longint):longbool;
|
||||
Function DosToWinTime (DTime:longint; var Wtime : TFileTime):longbool;
|
||||
|
||||
implementation
|
||||
|
||||
{$DEFINE HAS_GETMSCOUNT}
|
||||
@ -73,16 +76,50 @@ begin
|
||||
WinToDosAttr:=Attr;
|
||||
end;
|
||||
|
||||
|
||||
Function DosToWinTime (DTime:longint;Var Wtime : TFileTime):longbool;
|
||||
type
|
||||
Longrec=packed record
|
||||
lo,hi : word;
|
||||
end;
|
||||
|
||||
Function DosToWinTime (DTime:longint; var Wtime : TFileTime):longbool;
|
||||
var
|
||||
FatDate, FatTime: WORD;
|
||||
lft: TFileTime;
|
||||
st: SYSTEMTIME;
|
||||
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;
|
||||
|
||||
|
||||
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
|
||||
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;
|
||||
|
||||
|
||||
@ -481,17 +518,17 @@ end;
|
||||
|
||||
function envcount : longint;
|
||||
begin
|
||||
envcount:=0; //!!! fixme
|
||||
envcount:=0;
|
||||
end;
|
||||
|
||||
Function EnvStr (Index: longint): string;
|
||||
begin
|
||||
EnvStr:=''; //!!! fixme
|
||||
EnvStr:='';
|
||||
end;
|
||||
|
||||
Function GetEnv(envvar: string): string;
|
||||
begin
|
||||
GetEnv:=''; //!!! fixme
|
||||
GetEnv:='';
|
||||
end;
|
||||
|
||||
var
|
||||
|
@ -216,13 +216,13 @@ end;
|
||||
|
||||
Function DosToWinTime (DTime:longint; out Wtime : TFileTime):longbool;
|
||||
begin
|
||||
DosToWinTime:=False; //!!! fixme
|
||||
DosToWinTime:=dos.DosToWinTime(DTime, Wtime);
|
||||
end;
|
||||
|
||||
|
||||
Function WinToDosTime (Const Wtime : TFileTime; out DTime:longint):longbool;
|
||||
begin
|
||||
WinToDosTime:=False; //!!! fixme
|
||||
WinToDosTime:=dos.WinToDosTime(Wtime, DTime);
|
||||
end;
|
||||
|
||||
|
||||
@ -248,29 +248,23 @@ end;
|
||||
|
||||
Function FileExists (Const FileName : String) : Boolean;
|
||||
var
|
||||
Handle: THandle;
|
||||
FindData: TWin32FindData;
|
||||
fn: PWideChar;
|
||||
Attr:Dword;
|
||||
begin
|
||||
fn:=StringToPWideChar(FileName);
|
||||
Handle := FindFirstFile(PWideChar(widestring(FileName)), FindData);
|
||||
FreeMem(fn);
|
||||
Result:=Handle <> INVALID_HANDLE_VALUE;
|
||||
If Result then
|
||||
Windows.FindClose(Handle);
|
||||
Attr:=FileGetAttr(FileName);
|
||||
if Attr <> $ffffffff then
|
||||
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0
|
||||
else
|
||||
Result:=False;
|
||||
end;
|
||||
|
||||
|
||||
Function DirectoryExists (Const Directory : String) : Boolean;
|
||||
var
|
||||
Attr:Dword;
|
||||
fn: PWideChar;
|
||||
begin
|
||||
fn:=StringToPWideChar(Directory);
|
||||
Attr:=GetFileAttributes(fn);
|
||||
FreeMem(fn);
|
||||
Attr:=FileGetAttr(Directory);
|
||||
if Attr <> $ffffffff then
|
||||
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) > 0
|
||||
Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) <> 0
|
||||
else
|
||||
Result:=False;
|
||||
end;
|
||||
@ -339,7 +333,7 @@ Var
|
||||
FT : TFileTime;
|
||||
begin
|
||||
If GetFileTime(Handle,nil,nil,@ft) and
|
||||
WinToDosTime(FT,Result) then
|
||||
WinToDosTime(FT, Result) then
|
||||
exit;
|
||||
Result:=-1;
|
||||
end;
|
||||
@ -350,8 +344,7 @@ Var
|
||||
FT: TFileTime;
|
||||
begin
|
||||
Result := 0;
|
||||
if DosToWinTime(Age,FT) and
|
||||
SetFileTime(Handle, ft, ft, FT) then
|
||||
if DosToWinTime(Age, FT) and SetFileTime(Handle, FT, FT, FT) then
|
||||
Exit;
|
||||
Result := GetLastError;
|
||||
end;
|
||||
@ -651,17 +644,17 @@ end;
|
||||
|
||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||
begin
|
||||
Result := ''; //!!! fixme
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
begin
|
||||
Result := 0; //!!! fixme
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
begin
|
||||
Result := ''; //!!! fixme
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user