Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site trwrba.UUCP Path: utzoo!linus!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!trwrb!trwrba!mdf From: mdf@trwrba.UUCP (Mark D. Falleroni) Newsgroups: net.micro.atari Subject: ST Source: onedsk.c Message-ID: <1656@trwrba.UUCP> Date: Mon, 4-Nov-85 10:49:19 EST Article-I.D.: trwrba.1656 Posted: Mon Nov 4 10:49:19 1985 Date-Received: Fri, 8-Nov-85 05:18:29 EST Organization: TRW EDS, Redondo Beach, CA Lines: 71 The is an ST program that executes from the Hippo OS shell. It allows files (up to 28000 bytes) to be copied with only one disk swap. - - - - - - - - cut here - - - - - - - - cut here - - - - - - - - #include#define MEMBUF 28000 #define READ 0 #define WRITE 1 #define BUFSIZE 1024 main(argc,argv) int argc; char *argv[]; { int handle,n,bytes_read,cnt,i,c; char bigbuf[MEMBUF]; if (argc != 3) error("ONEDSK usage: onedsk source file destination file",NULL); printf("\nOpening %s\n",argv[1]); if ((handle = open(argv[1],READ)) < 0) error("ONEDSK: error opening %s",argv[1]); n=0; bytes_read=0; while ((n = read(handle,BUFSIZE,bigbuf+bytes_read)) > 0) { bytes_read += n; printf("Bytes read = %d\n",bytes_read); } close (handle); printf("\n\n"); printf("Insert destination disk in Drive A:\n"); printf("Type any key when ready\n"); necin(); /* get char with no screen echo */ printf("\nCreating %s on the destination disk\n",argv[2]); if ((handle = create(argv[2],0777)) < 0) /* if can't create it */ handle = open(argv[2],WRITE); /* try opening it */ if (handle < 0) error("ONEDSK: cannot create or open %s",argv[2]); if ((n = write(handle,bytes_read,bigbuf)) < 0) error("ONEDSK: error writing to %s",argv[2]); printf("\nBytes written = %d\n",n); close(handle); if (n == bytes_read) printf("\nCOPY COMPLETED\n\n"); else printf("\nBYTE COUNT MISMATCH: BAD COPY!\n\n"); } error(s1,s2) char *s1, *s2; { printf(s1,s2); printf("\n"); exit(1); }