[fpc-pascal] DirectoryExists on FreeBSD , problem
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Sat Oct 26 01:45:22 CEST 2019
On 14/10/2019 7:38 pm, Alexey Tor. wrote:
> >Does SysUtils.DirectoryExists work?
>
> No, the dir name is pure English, so DirectoryExistsUTF8 does the same.
:-) There is no such thing as "pure English".
I assume what you were trying to say, is that some text are encoded
differently, depending on the platform. So you might need to convert the
text to the OS Encoding.
eg: fpGUI uses the following, which all fpGUI based applications use, no
matter what platform they are on.
function fpgDirectoryExists(const ADirectory: TfpgString): Boolean;
begin
Result := DirectoryExists(fpgToOSEncoding(ADirectory));
end;
Then the fpgToOSEncoding() has different implementations for various
platforms (eg: Unix vs Windows)
// Unix (FreeBSD, Linux etc) - basically do nothing because those OSes
// use UTF-8 by default.
function fpgToOSEncoding(aString: TfpgString): string;
begin
Result := aString;
end;
// Under Windows I have this implementation
function fpgToOSEncoding(aString: TfpgString): string;
begin
Result := Utf8ToAnsi(aString);
end;
But as I mentioned, any application developer that uses fpGUI simply
needs to use the fpgDirectoryExists() method and doesn't need to worry
about encoding/decoding text.
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list