[Lazarus] FileExistsUTF8() difference between Unix/Windows
Bart
bartjunk64 at gmail.com
Sat Sep 21 18:24:28 CEST 2019
On Fri, Sep 20, 2019 at 8:56 PM Mattias Gaertner via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
Old Windows version:
> > >> 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;
> > >
> I added an incompatibility note:
> https://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes#LazUtils_Changes
I think that is incorrect.
As you can see above the old version also returned FALSE for
directories (it used the same logic as the Windows implementation of
FileExists).
The reason the implementation has changed is that since LCL is UTF8
the automatic conversion fpc does is now lossless, which it wasn't
before 3.0.
--
Bart
More information about the lazarus
mailing list