* * *

Author Topic: LazFileUtils and FileUtil clash  (Read 1525 times)

Windsurfer

  • Sr. Member
  • ****
  • Posts: 309
    • Windsurfer
LazFileUtils and FileUtil clash
« on: February 24, 2017, 11:17:37 am »
I have changed a gui app to use LazFileUtils rather than FileUtil, because LazFileUtils provides seamless UTF8.

However, the following no longer works unless I add FileUtil to the uses clause.
Code: Pascal  [Select]
  1. MyFilesize := FileSize(OpenDialog1.filename);

I get the error:
Compile Project, Mode: Normal, Target: WindSirf: Exit code 256, Errors: 1
mainscreen.pas(315,50) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "File"

Once FileUtil is added to the uses clause (immediately after LazFileUtils), everything works, but many warnings come up stating that FileUtil is deprecated and to use LazFileUtils.

Could someone please confirm this behaviour, and I'll raise a bug report to ask for filesize to be added to LazFileUtils.

I am using fpc 3.0.2 and laz 1.6 fixes on Linux Mint 18.1 Cinnamon on an Intel 64 bit platform

GetMem

  • Hero Member
  • *****
  • Posts: 2328
Re: LazFileUtils and FileUtil clash
« Reply #1 on: February 24, 2017, 11:24:56 am »
No need for bugreport:
Code: Pascal  [Select]
  1. MyFilesize := FileSizeUtf8(OpenDialog1.filename);

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3135
  • I like bugs.
Re: LazFileUtils and FileUtil clash
« Reply #2 on: February 24, 2017, 12:06:24 pm »
I agree with Windsurfer, this should be solved in a cleaner way. The ...UTF8() functions are not needed for anything else any more.
I think it could be solved with overloaded functions in LazFileUtils. The version taking "File" could be a wrapper for the RTL function maybe.
Windsurfer, can you please experiment with it and make a patch.

GetMem

  • Hero Member
  • *****
  • Posts: 2328
Re: LazFileUtils and FileUtil clash
« Reply #3 on: February 24, 2017, 12:16:07 pm »
@Juha
FileSize form FileUtils points to LazFileUtils.FileSizeUtf8(FileName). Do you wish to add an overloaded function for FileSize to LazFileUtils for backward compatibility?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3135
  • I like bugs.
Re: LazFileUtils and FileUtil clash
« Reply #4 on: February 24, 2017, 12:36:49 pm »
FileSize form FileUtils points to LazFileUtils.FileSizeUtf8(FileName). Do you wish to add an overloaded function for FileSize to LazFileUtils for backward compatibility?
Something like that. I didn't study the issue deeply now.
Actually backward compatibility breaks when a function is moved to another unit, but sometimes it is needed.

Windsurfer

  • Sr. Member
  • ****
  • Posts: 309
    • Windsurfer
Re: LazFileUtils and FileUtil clash
« Reply #5 on: February 27, 2017, 08:16:26 pm »
I am not the best person to create a patch. My coding skills are not good enough to dabble in the LCL.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus