🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.programmer.codewarrior
1 messages
1 total messages Started by 712311173 T.M. Steward Sun, 03 Sep 1995 20:10
Re: getline() dilemna - text or binary?
#9
Author: 712311173 T.M. Steward
Date: Sun, 03 Sep 1995 20:10
35 lines
1887 bytes
:>I need to process text files one line at a lime. 
:>
:>I'm wondering if anyone has come up with a convenient, efficient way to
:>read files a line at a time, regardless of the format of the text file?

I've found that using getline or any of the extractor-type
functions to be *extremely* inefficent(i.e. time-consuming).

If you don't need the portability, it's _much_ faster to
read the file using the DosRead() API in chunks that are
multiples of the cluster size.  Usually, for FAT drives
that's 4k.  I read at least 16k.  Then use a small state
machine to decode lines,blocks,whatever back to your program.
This is a convienient way also since you can not only handle
all the flavors of delimiters, but also comment lines,
tab expansion(another thing you forgot), quoted fields, etc..

This is just a bitch, but the latest 'C++' libs have so many
features, buffers, etc, that I have a hard time figuring out
how to effectively _use_ them.  This way, I'm in control.

If portability is a problem, you can use the 'C' lib fread()
instead.  It just calls DosRead on OS/2 anyway.

Setup a small class called textfile or similar with open,
close, readline;  That's what I do.


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>  On the net or on your knees ...
>>>
>>>  Tully Steward, Software Engineer
>>>  Weekdays: Tully_Steward%Compressor_Controls@MCIMAIL.com
>>>  Night/Weekends: 71231,1173@compuserve.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads