delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/28/13:16:45

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: read / write errors
Date: Sun, 28 Dec 1997 19:02:08 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 40
Message-ID: <34A69420.FABC7F0@LSTM.Ruhr-UNI-Bochum.De>
References: <684pm4$9ta AT mtinsc05 DOT worldnet DOT att DOT net>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Steve Patton wrote:
> 
> I am making an archive program, that uses (has nothing to do with the
> problem, but is using Allegro Compression Routines).  And here's what I do.
> 
[.:.]

> of course that's a snippet, with (hopefully) all you need to know.  It works
> with the first file, perfectly.  However, when it gets to the second, or
> more file, read does not read (or at least return) the correct size.  Such
> as the second file, it only says it read 690 bytes or so, when it's about
> 55,000 bytes, and then the next read returns 0, as if it were at the end of
> file.  The error (which is odd), I switched all read calls, with _dos_read
> calls (which should be compatible, since they are handle operated), and it
> works just fine.  How come "read" doesn't work correctly?  Who would I
> report this error too?
In DOS you must add O_BINARY to the open call. Otherwise, it'll
change all occurences of CR/LF to LF on read and vice versa on
write. And (and this is your problem) it terminates when
it hits a Ctrl-Z. 

BTW, this code looks like C++, so once your at it, why not use
the stream functions? Although this is just aesthetic and you'll
hit the same problem there (and maybe others...)


-- 
Ciao
Tom

*************************************************************
* Thomas Demmer                                             *
* Lehrstuhl fuer Stroemungsmechanik                         *
* Ruhr-Uni-Bochum                                           *
* Universitaetsstr. 150                                     *
* D-44780  Bochum                                           *
* Tel: +49 234 700 6434                                     *
* Fax: +49 234 709 4162                                     *
* http://www.lstm.ruhr-uni-bochum.de/~demmer                *
*************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019