Mail Archives: djgpp/1997/05/03/06:04:50
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 -