Path: utzoo!attcan!uunet!decwrl!ucbvax!ucdavis!csusac!jetfuel From: jetfuel@csusac.csus.edu (Dave Jenks) Newsgroups: comp.unix.internals Subject: Re: Need efficient way to read file in reverse Summary: You're trying too hard. Message-ID: <1990Sep19.055846.14004@csusac.csus.edu> Date: 19 Sep 90 05:58:46 GMT References: <1990Sep18.152818.1303@phri.nyu.edu> Reply-To: jetfuel@csusac.UUCP (Dave Jenks) Organization: California State University, Sacramento Lines: 17 In article <1990Sep18.152818.1303@phri.nyu.edu> roy@alanine.phri.nyu.edu (Roy Smith) writes: > Is there a standard, portable, efficient way to read a file in >reverse? I'm doing random seeks in a file and occassionally want to be able >to find the beginning of the line into the middle of which I just seeked. >Right now, I'm using a simple-minded revgetc() I wrote which is basically: I had to do the very same thing a number of years ago. The most efficient method was to read using read(2) for BLKSIZ bytes (#defined in or or someplace like that) and search the buffer manually. With a simple searching algorithm, this can be very fast - even with a poor algorithm, it'll still be much faster than asking for i/o for each character. It's even portable. -- ======================================================================= "Pro is to con, as progress is to Congress..." ...!uunet \