Thread overview
OSX stream seek/read problem
Feb 25, 2009
wade
Feb 25, 2009
Kagamin
Feb 25, 2009
Kagamin
Feb 26, 2009
wade
Mar 30, 2009
Sean Kelly
February 25, 2009
The following code behaves differently on OSX than LINUX (DMD 1.040):

import std.stdio;
import std.stream;
import std.file;

int Lines(Stream f)
{
  int ln = 0;

  foreach (char[] line; f) ln++;
  return ln;
}

void main(char[][] args)
{
  auto f = new BufferedFile(args[1]);
  int l = Lines(f);
  f.seek(0, SeekPos.Set);
  int r = Lines(f);
  fwritef(stderr, "Lines before: %d, Lines after: %d\n", l, r);
}

Results for OSX:
Lines before: 1633, Lines after: 0

Results for LINUX
Lines before: 1633, Lines after: 1633

Seek not working properly perhaps?

wade


February 25, 2009
wade Wrote:

> Seek not working properly perhaps?

May be related... http://www.opendarwin.info/opendarwin.org/en/faq/ch04.html#lseek
February 25, 2009
Kagamin Wrote:

> wade Wrote:
> 
> > Seek not working properly perhaps?
> 
> May be related... http://www.opendarwin.info/opendarwin.org/en/faq/ch04.html#lseek

seems like phobos needs some error handling.
February 26, 2009
looks like a candidate.  Probably a bug in phobos.

Kagamin Wrote:

> Kagamin Wrote:
> 
> > wade Wrote:
> > 
> > > Seek not working properly perhaps?
> > 
> > May be related... http://www.opendarwin.info/opendarwin.org/en/faq/ch04.html#lseek
> 
> seems like phobos needs some error handling.

March 30, 2009
This will be fixed in DMD 2.027.  I haven't looked into it for DMD1 yet though.