www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Error closing BufferedFile before eof

reply Piotr Fusik <Piotr_member pathlink.com> writes:
The following produces the error message "unable to move file pointer": (DMD
0.122/Windows)

private import std.stream;

void main(char[][] args) {
Stream s = new BufferedFile("foo"); // "foo" exists
ubyte b;
s.read(b);
s.close();
}
May 17 2005
parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"Piotr Fusik" <Piotr_member pathlink.com> wrote in message 
news:d6dcr8$e1e$1 digitaldaemon.com...
 The following produces the error message "unable to move file pointer": 
 (DMD
 0.122/Windows)

 private import std.stream;

 void main(char[][] args) {
 Stream s = new BufferedFile("foo"); // "foo" exists
 ubyte b;
 s.read(b);
 s.close();
 }

odd. I can't reproduce the problem. The error is coming from a failed attempt to "seek". Are you sure those are the reproduction steps?
May 17 2005
parent reply Piotr Fusik <Piotr_member pathlink.com> writes:
odd. I can't reproduce the problem. The error is coming from a failed 
attempt to "seek". Are you sure those are the reproduction steps? 

May 17 2005
parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"Piotr Fusik" <Piotr_member pathlink.com> wrote in message 
news:d6delc$fqb$1 digitaldaemon.com...
odd. I can't reproduce the problem. The error is coming from a failed
attempt to "seek". Are you sure those are the reproduction steps?


hmm. I'll try to find a Win98 box. I was also using dmd.123 but I'm not aware of any bug fixes that should have changed the stream behavior between dmd.122 and dmd.123. Maybe the directory and/or file read/write privledges are different from my first test. It would be useful to know if someone else reading the newsgroup can reproduce it, too.
May 17 2005
parent reply Piotr Fusik <Piotr_member pathlink.com> writes:
The solution is to change the following line of std.stream.d:
long diff = bufferCurPos-bufferSourcePos;
to:
long diff = cast(long) bufferCurPos - bufferSourcePos;
May 18 2005
parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Piotr Fusik" <Piotr_member pathlink.com> wrote in message 
news:d6f4dr$1u6e$1 digitaldaemon.com...
 The solution is to change the following line of std.stream.d:
 long diff = bufferCurPos-bufferSourcePos;
 to:
 long diff = cast(long) bufferCurPos - bufferSourcePos;

whew! thanks for trying that out.
May 18 2005