[Lazarus] FileExistsUTF8() difference between Unix/Windows

Bart bartjunk64 at gmail.com
Wed Sep 18 23:48:17 CEST 2019


On Wed, Sep 18, 2019 at 11:26 PM Torsten Bonde Christiansen via
lazarus <lazarus at lists.lazarus-ide.org> wrote:

> No entirely though. The Unix version is mostly a wrapper, yes - but the
> Windows version do some additional filtering:
>
> function FileExistsUTF8(const Filename: string): boolean;
> var
>    Attr: Longint;
> begin
>    Attr := FileGetAttrUTF8(FileName);
>    if Attr <> -1 then
>      Result:= (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0
>    else
>      Result:=False;
> end;

Not anymore in trunk:

function FileExistsUTF8(const Filename: string): boolean;
begin
  Result := SysUtils.FileExists(Filename);
end;

This will return False for directories.
(The test for (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0 is done by fpc now).

On *nix everything is a file, so folders are reported to be files as well AFAIK.

--
Bart



-- 
Bart


More information about the lazarus mailing list