FIX: Access denied checking (fixes #1725)

(cherry picked from commit a0a9221472)
This commit is contained in:
Alexander Koblov 2024-06-21 21:54:26 +03:00
commit 638fa8a748
2 changed files with 14 additions and 1 deletions

View file

@ -324,7 +324,7 @@ begin
with aFileView do
CurrentPath := CurrentPath + IncludeTrailingPathDelimiter(aFile.Name);
end
else if ElevationRequired(LastError) then
else if AccessDenied(LastError) then
begin
sPath:= ReadSymLink(aFile.FullPath);
if sPath <> EmptyStr then

View file

@ -166,6 +166,8 @@ function mbFileNameToSysEnc(const LongPath: String): String;
}
function mbFileNameToNative(const FileName: String): NativeString; inline;
function AccessDenied(LastError: Integer): Boolean; inline;
procedure FixFormIcon(Handle: LCLType.HWND);
procedure HideConsoleWindow;
procedure FixDateNamesToUTF8;
@ -756,6 +758,17 @@ begin
end;
{$ENDIF}
function AccessDenied(LastError: Integer): Boolean;
{$IF DEFINED(MSWINDOWS)}
begin
Result:= (LastError = ERROR_ACCESS_DENIED);
end;
{$ELSE}
begin
Result:= (LastError = ESysEPERM) or (LastError = ESysEACCES);
end;
{$ENDIF}
procedure FixFormIcon(Handle: LCLType.HWND);
begin
// Workaround for Lazarus issue 0018484.