[Lazarus] FileExistsUTF8() difference between Unix/Windows
Michael Van Canneyt
michael at freepascal.org
Thu Sep 19 00:02:19 CEST 2019
On Wed, 18 Sep 2019, Bart via lazarus wrote:
> 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.
SysUtils.FileExists also returns false for directories, to match windows
behavour.
Michael.
More information about the lazarus
mailing list