Re: uncompressing data in memory

From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 06/22/04


Date: 22 Jun 2004 12:33:25 GMT

In <g36fd0hr60e5cm0dju6hail1pgkn0bf93h@4ax.com> Jack Klein <jackklein@spamcop.net> writes:

>On Tue, 22 Jun 2004 00:51:24 +0200, Slaanesh <slaanesh@no-log.org>
>wrote in comp.lang.c:
>
>>fseek(file, 0, SEEK_END);
>
>If your file contains compressed data, it is almost certainly binary
>and not text. Yet you have opened it in text mode. Also, SEEK_END
>has undefined behavior for binary files,

Chapter and verse, please. AFAICT, "need not meaningfully support" is
FAR from invoking undefined behaviour.

>although it might not work all that well for text files either.

It is *guaranteed* to work for text streams, when offset is 0. Otherwise,
using SEEK_END is genuine undefined behaviour (violation of a "shall"):

4 For a text stream, either offset shall be zero, or offset shall
     be a value returned by an earlier successful call to the ftell
     function on a stream associated with the same file and whence
     shall be SEEK_SET.

Dan

-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de


Relevant Pages

  • Re: fseek
    ... the results of ftell on a binary stream are ... by ftell on a text stream need not be a plain byte offset. ... Dan Pop ...
    (comp.lang.c)
  • Re: fseek
    ... >"For a text stream, either offset shall be zero, or offset shall be a ... The other stream *must* be a text stream too. ... Dan Pop ...
    (comp.lang.c)
  • Example 4
    ... Or one wants to pass the memory stream to different classess... ... location in the buffer. ... the offset in the constructor... ...
    (alt.comp.lang.borland-delphi)
  • Re: starting streams at offsets
    ... System.IO.Stream which represents another stream starting from offset X. ... public override bool CanRead{ ... memory when it gets constructed. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: [9fans] Streaming 9P is out
    ... the client only gets the dial string of a new tcp connection. ... attacker could guess the port numbers and take over the stream. ... should know the current offset and mode from the Chan structure right? ...
    (comp.os.plan9)