Recent

Author Topic: 'FileExistsUTF8" is deprecated: what to use then?  (Read 10204 times)

frederic

  • Full Member
  • ***
  • Posts: 226
'FileExistsUTF8" is deprecated: what to use then?
« on: May 03, 2017, 01:38:51 pm »
dear specialists
i get following warning:
Quote
laadunit1.pas(785,27) Warning: Symbol "FileExistsUTF8" is deprecated: "Use the function in LazFileUtils unit"

what is the name of the alternative fuction where this refers to?

frederic

paweld

  • Hero Member
  • *****
  • Posts: 996
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #1 on: May 03, 2017, 01:57:01 pm »
FileExists
Best regards / Pozdrawiam
paweld

frederic

  • Full Member
  • ***
  • Posts: 226
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #2 on: May 03, 2017, 02:17:51 pm »
oh... simple,
i was used to use this in the past, and was forced to apply  the ....utf8 adapt and stayed with it since.
looking in LazfileUtils i only saw the old "fileexists" .
I return to the old function again and see .........what  comes i
thanks for the reaction
frederic

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #3 on: May 03, 2017, 03:21:41 pm »
Quote
laadunit1.pas(785,27) Warning: Symbol "FileExistsUTF8" is deprecated: "Use the function in LazFileUtils unit"

FileExistsUtf8 function is in the LazUtf8 uit now.
It used to be in LCLProc of FileUtil unit.
Simply add LazUtf8 to your uses clause after LCLProc and/or FileUtil and your in the clear.

OTOH: as Paweld wrote, currently simply using FileExists (in Lazarus) should work, as long as the parameter is of type string (not UTF8String), and you did not define DisableUtf8RTL in your project options.
All this assuming you are not on Win9x, where (IIUC) you will still need the *UTF8() functions from LazUtf8.

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #4 on: May 03, 2017, 04:06:13 pm »
Oh, so this is just part of the UTF8 Lazarus f*ck-up reconstruction excercise? I appreciate that. 8-)
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #5 on: May 03, 2017, 04:57:37 pm »
Oh, so this is just part of the UTF8 Lazarus f*ck-up reconstruction excercise? I appreciate that. 8-)
What does that mean? What exactly is f*ck-up?
In my experience Unicode is now supported better than ever.
The answer from paweld was correct. Just use the Delphi compatible FileExists(). Is there something wrong with such a solution?
Bart's answer in this context was not useful, especially if it triggered your negative reaction. It listed 2 corner cases which most people can ignore.

Anyway Thaddy, please try to be more positive and constructive. It is not nice to always find something negative of things discussed.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #6 on: May 03, 2017, 06:59:48 pm »
Bart's answer in this context was not useful, especially if it triggered your negative reaction. It listed 2 corner cases which most people can ignore.

Please don't be so harsh on me.
My answer to the original question is the correct one from the perspective of the given message, except that where I wrote LazUtf8, you are supposed to read LazFileUtils.
If you want to use FileExistsUtf8, you are now supposed to call the one from LazFileUtils.

The suggestion to uses FileExists is not an answer to the question "what is the name of the alternative fuction where this refers to?", where this refers to the  "Use the function in LazFileUtils unit" part of the compiler message.

That being said: using FileExists instead of FileExistsUtf8 is the future way to go.
In almost all use cases there is no need for the UTF8 file functions anymore.

B.t.w. I like corner cases  >:D

Bart

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #7 on: May 03, 2017, 07:09:46 pm »
Oh, so this is just part of the UTF8 Lazarus f*ck-up reconstruction excercise? I appreciate that. 8-)

Excuse me?
I feel offended by that remark.
In the past we have worked very hard to have unicode support in file functions.
Before the 3.0 series compiler this was not possible using standard fpc libraries. We had to explicitely translate UTF8 encoded strings to WideString (Windows platform) just to be able to call the W-API.
This has made Lazarus unicode enabled long before the compiler helped us with that with it's codepage magic.

The "deprecated" messages is a result of sanitizing the FileUtil and LazFileUtils units, which we did long time ago (IIRC before the release of fpc 3.0).

And now we seem to be in yet anther transition where we can get rid of the UTF8 file functions alltogether in the future.
So, there probably wil be more deprecation going on in this area.

Calling this "f*ck-up" is just spiteful.

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #8 on: May 03, 2017, 07:24:15 pm »
My answer to the original question is the correct one from the perspective of the given message, except that where I wrote LazUtf8, you are supposed to read LazFileUtils.
If you want to use FileExistsUtf8, you are now supposed to call the one from LazFileUtils.
True, there were 2 separate things: deprecation of function wrappers and the bigger change in Unicode support.
As both changes were related to Unicode they were made around the same time.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: 'FileExistsUTF8" is deprecated: what to use then?
« Reply #9 on: May 03, 2017, 08:27:30 pm »
Thaddy likes to spam everything with nonsense comments. Especially FPC bug reports - he comments and disputes everything even if he doesn't try to understand the issue and is wrong in most cases. I am so happy he is not very active on Lazarus mantis.

Well and that you don't say I don't bring any proofs. Just from today:
https://bugs.freepascal.org/view.php?id=31746
https://bugs.freepascal.org/view.php?id=31714

 

TinyPortal © 2005-2018