Need efficient way to read file in reverse

Chuck Ocheret chuck at Morgan.COM
Fri Sep 28 01:38:30 AEST 1990


I recommend that you check to see if your system supports some form of
memory mapping of a file.  On some systems there is the mmap(2) call on
others a version of shmat(2) allows you to do mostly the same thing.
Not all systems provide such a mechanism.  When you map a file in using
either of these you get a pointer to memory which maps directly to a
specified file on the file system (can also be a device).  This gives
you full random access to all bytes in the file.  Read it backwards,
forwards, or however you wish; your file has just become a char *.

~chuck
-- 
+--------------------+   Chuck Ocheret, Sr. Staff Engineer   +---------------+
|chuck at APT.Morgan.COM|       Morgan Stanley & Co., Inc.      |(212) 703-4474 |
|    Duty now ...    |19th Floor, 1251 Avenue of the Americas|for the future.|
+--------------------+      New York, N.Y.  10020 USA        +---------------+



More information about the Comp.unix.internals mailing list