[Lazarus] Reworked ReadFileToString to support Linux virtual files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Reworked ReadFileToString to support Linux virtual files

Free Pascal - Lazarus mailing list
https://bugs.freepascal.org/view.php?id=36145

Last attached demo contains my reworked function (after the fix it works
pretty fast, i tested it). Can you apply at least this function? The
issue can be opened - issue is about IDE. The function is reworked to
support Linux virtual files like /proc/version, /proc/meminfo.

--
Regards,
Alexey

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Reworked ReadFileToString to support Linux virtual files

Free Pascal - Lazarus mailing list


On Sat, 9 Nov 2019, AlexeyT via lazarus wrote:

> https://bugs.freepascal.org/view.php?id=36145
>
> Last attached demo contains my reworked function (after the fix it works
> pretty fast, i tested it). Can you apply at least this function? The
> issue can be opened - issue is about IDE. The function is reworked to
> support Linux virtual files like /proc/version, /proc/meminfo.

Concerning
"Btw, i could not make this func using "file of byte" or "file" types for BlockRead, in that cases i always got IOResult=5 (Access denied) so i 've used TextFile type (IOResult is ok)."


file of byte or untyped files are always opened read/write.
The FileMode variable can be set to avoid that.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Reworked ReadFileToString to support Linux virtual files

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Fri, Nov 8, 2019 at 11:09 PM AlexeyT via lazarus
<[hidden email]> wrote:
> Last attached demo contains my reworked function (after the fix it works
> pretty fast, i tested it). Can you apply at least this function? The
> issue can be opened - issue is about IDE. The function is reworked to
> support Linux virtual files like /proc/version, /proc/meminfo.

I am hesitant to apply it because IMO it is not well optimized. It
uses TFileStream, then a char buffer and then the Result string. Data
is moved between them 3 times, isn't it?
Another reason for hesitation: we don't have any acute bug concerning
function ReadFileToString() that needs fixing. Yes I know the current
function does not work with virtual files in Unix systems. Fixing that
is a good idea but the new function should be as fast or faster than
the current one which calls FileSize(). What is the overhead caused by
FileSize()? I don't know but the speed of potential ReadFileToString()
replacements should be compared. Did you compare them?
If somebody comes up with a good optimised version, I promise to apply it.

One problem is also that you often concentrate on trivial unimportant
details of Lazarus sources instead of fixing real bugs.
I know real bugs require diving deep into the code, hours of studying
and debugging. It is harder than the trivial changes but there is no
alternative when fixing the really nasty bugs.

Juha
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus