Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2019-11

Reworked ReadFileToString to support Linux virtual files

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to AlexeyT
AlexeyT wrote 6 lines
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.

Reply by email

Juha Manninen
to AlexeyT: https://bugs.freepascal.org/view.php?id=36145 Last attached demo contains my reworked…
PM AlexeyT 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

Reply by email