delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/03/06:04:50

Date: Sat, 3 May 1997 17:49:21 +0800 (GMT)
From: Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph>
To: Ethan Rohrer <rer AT wlv DOT iipo DOT gtegsc DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: help: read()ing from files containing 0x1A
In-Reply-To: <E9KKxq.E3L@wlbr.iipo.gtegsc.com>
Message-ID: <Pine.SGI.3.93.970503174506.9169A-100000@gibson.eee.upd.edu.ph>
MIME-Version: 1.0

On Fri, 2 May 1997, Ethan Rohrer wrote:

> 
> Hello all,
> 
> I am trying to port some code from my UNIX account to my DOS machine.
> My program reads a binary file using a open()/read()/close() sequence.
> It worked like a champ in my UNIX account.
> 
> Now, under DJGPP, I find that read() stops reading when it encounters
> the EOF character (0x1A), which just happens to occur every here and
> there in my binary files...

In your open() call, add O_BINARY to the flags. Note that this is
nonportable to UNIX, so you do something like:

#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

#ifdef MSDOS
 i = open ("myfile", O_RDWR | O_BINARY);
#else
 i = open ("myfile", O_RDWR);
#endif


-----------------------------------------------------------------------
Orlando Alcantara Andico
WWW:   http://www2.mozcom.com/~orly/           Email:   orly AT mozcom DOT com
ICBM:  14 deg. 30' N, 120 deg. 59' E           POTS:    (+632) 932-2385

- Raw text -


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