On 14.10.2010 22:14, Steven Schveighoffer wrote:
On Thu, 14 Oct 2010 13:39:03 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
On 10/14/10 12:27 CDT, Steven Schveighoffer wrote:
On Thu, 14 Oct 2010 11:34:12 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
Please, use the term "seek", and allow an anchor. Every OS allows this,
it makes no sense not to provide it.
I've always thought that's a crappy appendix. Every OS that ever
allows seek/tell with anchors allows ALL anchors, and always allows
either both or none of seek and tell. So I decided to cut through the
crap and simplify. You want to seek 100 bytes from here, you write
stream.position = stream.position + 100.
Um.. yuck. We need to use two system calls to seek 100 bytes?
Oh, that reminds me I need to provide length as a property as well.
This would save us crap like seek(0, SEEK_END); ftell() to figure out
the length of a file.
So now you need to do stream.position = stream.length to seek to the
end of the file instead of stream.seek(0, Anchor.END)? Plus, how will
you implement length, probably like this:
auto curpos = seek(0, SEEK_CUR);
auto len = seek(0, SEEK_END);
seek(curpos, SEEK_BEG);
return len;
Actually C Run-time library provides something very limited from the
point of most native OS I/O functions,
at very least, Windows and Posix have a separate function for
determining file length.
[snip]
-Steve
--
Dmitry Olshansky