#147383 - 2005-09-09 09:56 AM
Re: enhance readline() to return the whole buffer at once
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I'd prefer raw file i/o as a solution something like Code:
$fdFile=fOpen("c:\temp\file.txt",2+8) ; Open for reading (in binary mode) $=fSeek($fdFile,-1) ; Fast forward to end of file $lFileSize=fTell($fdFile) ; How big is file? $=fRewind($fdFile) ; Back to start of file $FileData=fRead($fdFile,$lFileSize) ; Read entire file into buffer
|
|
Top
|
|
|
|
#147385 - 2005-09-28 01:19 AM
Re: enhance readline() to return the whole buffer at once
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
Hey, I want this raw I/O stuff too, I've had to use kludges to get around the lack of support binary reads and seeks.. And make the fRead with a 3rd parameter specificing the size of the buffer in case you only want xxx bytes from the seek point. Please... pretty please
|
|
Top
|
|
|
|
#147386 - 2005-09-28 03:56 AM
Re: enhance readline() to return the whole buffer at once
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
What do you guys think about having the flexibility of setting the end-of-line character for READLINE? That way we could have a great deal of flexibility in reading partial or complete files into a variable. We could set the line separator to "" and read the entire file. Or we could set the EOL value to some other value to split lines during the READLINE.
|
|
Top
|
|
|
|
#147388 - 2005-09-28 10:29 AM
Re: enhance readline() to return the whole buffer at once
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
And make the fRead with a 3rd parameter specificing the size of the buffer in case you only want xxx bytes from the seek point. Please... pretty please
No need for a third parameter.
The second parameter in the pseudo-code is the buffer size. As this topic is about reading the entire file I set the read size to the size of the file in the example, but it could be any value.
|
|
Top
|
|
|
|
#147389 - 2005-09-28 02:01 PM
Re: enhance readline() to return the whole buffer at once
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
And if you are going to enhance do it right so I suggested not to limit yourself to only read the entire file but optionally specify a buffer in case you only want a part of a (binary) file. A standard function in most other languages.
|
|
Top
|
|
|
|
#147390 - 2005-09-28 03:07 PM
Re: enhance readline() to return the whole buffer at once
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
And if you are going to enhance do it right so I suggested not to limit yourself to only read the entire file but optionally specify a buffer in case you only want a part of a (binary) file. A standard function in most other languages.
At the risk of my repeating myself that is exactly what it does.
Re-read the pseudo-code, and if you still don't understand how it does partial file reads send me a PM and I'll explain off-line.
|
|
Top
|
|
|
|
#147391 - 2005-09-28 08:56 PM
Re: enhance readline() to return the whole buffer at once
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
You're right of course Richard, ignore my previous babbling. I completely misread the pseudo code for some reason.
|
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 414 anonymous users online.
|
|
|