Re: Application Reading Itself
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sun, 02 Jul 2006 19:46:56 GMT
"ReaperUnreal" <reaperunreal@xxxxxxxxx> writes:
Actually, I found the problem myself, and you were all way off. You'll
carefully notice that I fseek to the end of the file with a -8 offset.
Apparently, the offset is ignored if I use the SEEK_END flag. So an
additional fseek solved the problem.
Please provide some context when you post a followup.
According to the C standard:
For a binary stream, the new position, measured in characters from
the beginning of the file, is obtained by adding offset to the
position specified by whence. The specified position is the
beginning of the file if whence is SEEK_SET, the current value of
the file position indicator if SEEK_CUR, or end-of-file if
SEEK_END. A binary stream need not meaningfully support fseek
calls with a whence value of SEEK_END.
The last sentence is intended to cover systems that don't store the
exact size in bytes of a binary file; for example, a binary file can
legally be implicitly padded with null bytes up to a multiple of some
block size. As far as I know, it's unlikely that any system you're
likely to be using is affected by this.
In other words, I'd be very surprised if fseek() with the SEEK_END
flag actually did ignore the offset (though it's allowed by the
standard). Though you may be correct, my guess is that you've somehow
misunderstood what's really going on, and your fix works only by
accident.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- Re: Application Reading Itself
- From: Barry Schwarz
- Re: Application Reading Itself
- From: ReaperUnreal
- Re: Application Reading Itself
- Prev by Date: Re: BOMDAS Vs BODMAS
- Next by Date: Re: The C Programming Language: Third Edition
- Previous by thread: Re: Application Reading Itself
- Next by thread: Re: Application Reading Itself
- Index(es):
Relevant Pages
|