Article View: comp.sys.atari.st
Article #26798Megamax Binary Files
From: nowlin
Date: Thu, 14 May 1987 18:21
Date: Thu, 14 May 1987 18:21
45 lines
1706 bytes
1706 bytes
I've noticed a problem with Megamax and reading binary files. The
following code is used to copy one file to another. It works fine except
that the file being copied, the one being read, gets one byte longer after
every copy.
if ((in = fopen(old,"br")) == NULL) {
fprintf(stderr,"ERROR: can't open '%s' to read\n",old);
return 0;
}
if ((out = fopen(new,"bw")) == NULL) {
fprintf(stderr,"ERROR: can't open '%s' to write\n",new);
fclose(in);
return 0;
}
setbuf(in,ibuf);
setbuf(out,obuf);
while ((len = fread(buff,1,CPBLEN,in)) > 0) {
if (fwrite(buff,1,len,out) != len) {
fprintf(stderr,"ERROR: write error on '%s'\n",new);
ret = 0;
break;
}
}
if (fclose(in) < 0) {
fprintf(stderr,"ERROR: close error on '%s'\n",old);
ret = 0;
}
if (fclose(out) < 0) {
fprintf(stderr,"ERROR: close error on '%s'\n",new);
ret = 0;
}
I can't think of any reason why a file opened for read would get longer
after it was read all the way to the end. Has anyone else run into this
problem and found a way to fix it? Thanks for any help that can be
offered. I really like Megamax but this is strange.
Jerry Nowlin
(...!ihnp4!ihuxy!nowlin)
Technical Details
Message-ID:
<1971@ihuxy.ATT.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbatt!ihnp4!ihuxy!nowlinShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbatt!ihnp4!ihuxy!nowlin From: nowlin@ihuxy.UUCP Newsgroups: comp.sys.atari.st Subject: Megamax Binary Files Message-ID: <1971@ihuxy.ATT.COM> Date: Thu, 14-May-87 14:21:40 EDT Article-I.D.: ihuxy.1971 Posted: Thu May 14 14:21:40 1987 Date-Received: Sat, 16-May-87 09:48:53 EDT Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 45 Keywords: read writes, binary files