www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - OSX stream seek/read problem

reply wade <swadenator gmail.com> writes:
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
Feb 25 2009
next sibling parent reply Kagamin <spam here.lot> writes:
wade Wrote:

 Seek not working properly perhaps?

May be related... http://www.opendarwin.info/opendarwin.org/en/faq/ch04.html#lseek
Feb 25 2009
parent reply Kagamin <spam here.lot> writes:
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.
Feb 25 2009
parent wade <swadenator gmail.com> writes:
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.

Feb 25 2009
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
This will be fixed in DMD 2.027.  I haven't looked into it for DMD1 yet 
though.
Mar 30 2009