mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 02:49:19 +02:00
LCL: changed INVALID_HANDLE_VALUE from 0 to LCLType.Handle(-1), -1 is the Windows value
git-svn-id: trunk@41517 -
This commit is contained in:
parent
2eaea5eb94
commit
822ca4c2e1
@ -380,7 +380,7 @@ var
|
|||||||
FindData: TWin32FindDataW;
|
FindData: TWin32FindDataW;
|
||||||
begin
|
begin
|
||||||
Hnd := FindFirstFileW(PWideChar(UTF8ToUTF16(FileName)), FindData);
|
Hnd := FindFirstFileW(PWideChar(UTF8ToUTF16(FileName)), FindData);
|
||||||
if Hnd <> INVALID_HANDLE_VALUE then
|
if Hnd <> Windows.INVALID_HANDLE_VALUE then
|
||||||
begin
|
begin
|
||||||
Windows.FindClose(Hnd);
|
Windows.FindClose(Hnd);
|
||||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
|
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
|
||||||
@ -534,7 +534,7 @@ begin
|
|||||||
{ $1e = faHidden or faSysFile or faVolumeID or faDirectory }
|
{ $1e = faHidden or faSysFile or faVolumeID or faDirectory }
|
||||||
{ FindFirstFile is a Win32 Call }
|
{ FindFirstFile is a Win32 Call }
|
||||||
Rslt.FindHandle:=Windows.FindFirstFileW( PWideChar(UTF8Decode(Path)),find);
|
Rslt.FindHandle:=Windows.FindFirstFileW( PWideChar(UTF8Decode(Path)),find);
|
||||||
If Rslt.FindHandle=Invalid_Handle_value then
|
If Rslt.FindHandle=Windows.Invalid_Handle_value then
|
||||||
begin
|
begin
|
||||||
Result:=GetLastError;
|
Result:=GetLastError;
|
||||||
Exit;
|
Exit;
|
||||||
|
@ -55,6 +55,9 @@ uses
|
|||||||
IpUtils,
|
IpUtils,
|
||||||
IpConst;
|
IpConst;
|
||||||
|
|
||||||
|
const
|
||||||
|
IpFileOpenFailed = -1;
|
||||||
|
|
||||||
{ TIpMemMapStream }
|
{ TIpMemMapStream }
|
||||||
type
|
type
|
||||||
TIpMemMapStream = class(TStream)
|
TIpMemMapStream = class(TStream)
|
||||||
@ -1580,12 +1583,12 @@ end;
|
|||||||
|
|
||||||
constructor TIpDownloadFileStream.Create(const aPath : string);
|
constructor TIpDownloadFileStream.Create(const aPath : string);
|
||||||
begin
|
begin
|
||||||
FHandle := INVALID_HANDLE_VALUE;
|
FHandle := IpFileOpenFailed;
|
||||||
inherited Create;
|
inherited Create;
|
||||||
dfsMakeTempFile(aPath);
|
dfsMakeTempFile(aPath);
|
||||||
|
|
||||||
FHandle := THandle(FileOpen(FFileName, fmShareDenyNone + fmOpenReadWrite));
|
FHandle := THandle(FileOpen(FFileName, fmShareDenyNone + fmOpenReadWrite));
|
||||||
if (Handle = INVALID_HANDLE_VALUE) then
|
if (Handle = IpFileOpenFailed) then
|
||||||
{$IFDEF Version6OrHigher}
|
{$IFDEF Version6OrHigher}
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -1651,7 +1654,7 @@ begin
|
|||||||
{$IFNDEF IP_LAZARUS}
|
{$IFNDEF IP_LAZARUS}
|
||||||
CloseHandle(Handle);
|
CloseHandle(Handle);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FHandle := INVALID_HANDLE_VALUE;
|
FHandle := IpFileOpenFailed;
|
||||||
{calculate the full new name}
|
{calculate the full new name}
|
||||||
NewFullName := FPath + '\' + aNewName;
|
NewFullName := FPath + '\' + aNewName;
|
||||||
{rename the file}
|
{rename the file}
|
||||||
@ -1671,7 +1674,7 @@ begin
|
|||||||
{ do nothing }
|
{ do nothing }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Handle = INVALID_HANDLE_VALUE) then
|
if (Handle = IpFileOpenFailed) then
|
||||||
{$IFDEF Version6OrHigher}
|
{$IFDEF Version6OrHigher}
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -1690,7 +1693,7 @@ begin
|
|||||||
{$IFNDEF IP_LAZARUS}
|
{$IFNDEF IP_LAZARUS}
|
||||||
CloseHandle(Handle);
|
CloseHandle(Handle);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FHandle := INVALID_HANDLE_VALUE;
|
FHandle := IpFileOpenFailed;
|
||||||
{copy the file} {!!.01}
|
{copy the file} {!!.01}
|
||||||
{$IFDEF Version6OrHigher}
|
{$IFDEF Version6OrHigher}
|
||||||
{$IFNDEF IP_LAZARUS}
|
{$IFNDEF IP_LAZARUS}
|
||||||
@ -1710,7 +1713,7 @@ begin
|
|||||||
{ do nothing }
|
{ do nothing }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Handle = INVALID_HANDLE_VALUE) then
|
if (Handle = IpFileOpenFailed) then
|
||||||
{$IFDEF Version6OrHigher}
|
{$IFDEF Version6OrHigher}
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
|
@ -152,7 +152,7 @@ type
|
|||||||
PHKEY = ^HKEY;
|
PHKEY = ^HKEY;
|
||||||
|
|
||||||
const
|
const
|
||||||
INVALID_HANDLE_VALUE = 0;
|
INVALID_HANDLE_VALUE = HANDLE(-1); // prior to 1.1 it was 0, see for example FileOpen
|
||||||
|
|
||||||
MAXBYTE = Byte($FF);
|
MAXBYTE = Byte($FF);
|
||||||
MAXWORD = Word($FFFF);
|
MAXWORD = Word($FFFF);
|
||||||
|
Loading…
Reference in New Issue
Block a user