[REBOL] Re: skip on direct mode file port
From: gscottjones:mchsi at: 12-Aug-2002 7:49
Hi, Anton,
From: "Anton"
> I want to read the last 128 bytes of
> mpeg audio files.
> I have fixed up and am fixing up mp3tool.r
> from the script library, which reads id3v1 tags.
> Currently, it is reading the whole
> file into memory, which is wasteful.
>
> Is there a way to get the file pointer
> to the end without reading the whole file?
>
> I have a half-solution:
> Do a buffered read, with the buffer
> set to 128 bytes, such that the last
> buffer contents falls over the last
> 128 bytes. Or could use a larger buffer
> until the last 128 bytes.
> Mmm. I don't like it. It's just for fun,
> so I can wait, too.
This is not the most efficient method, but it does allow skipping within an
unbuffered access:
my-blk: copy []
fs: size? %license.html
fr: open/direct/binary %license.html
loop (fs - 178) [copy/part fr 1]
loop 178 [append my-blk copy/part fr 1]
close fr
Hope this helps until skip is repaired for direct/binary.
--Scott Jones