/* * RT2MS1.C Program to copy a file to an MS-DOS directory format disk * * Copyright (c) 1991 Shal Farley * Cheshire Engineering Corporation * 650 Sierra Madre Villa Avenue, Suite 201 * Pasadena, California 91107 * (818) 351-5493 * (818) 351-8645 FAX * shal@alumni.caltech.edu * * This software may be used and distributed for any purpose without license or * royalty payments so long as the above copyright notice is preserved. If you * have any comments, bug fixes, improvements, or new programs based upon this * software I'd like to hear from you. */ #include #ifdef __STDC__ # include #else # include "stdlib.h" #endif #include "msport.h" #include "msdefs.h" #include "msfio.h" #include "msdir.h" #define BUFSIZE (16*512) /* Read 16 blocks (sectors) at a time */ UCHAR buf[BUFSIZE]; main(argc,argv) int argc; char *argv[]; { FILE *pFin; MSFILE *pFout; int len; int buflen; int i; char busy[5]; if (argc != 3) { printf("Usage: RT2MS1 [dev:]rtfilespec dev:msfilespec"); } if ((pFin = fopen(argv[1], "rn")) == NULL) Fail(argv[1]); if ((pFout = msfopen(argv[2], "w")) == NULL) Fail(argv[2]); printf("Copying %s to %s:%s ", pFin->io_name, ((MSDEV *)pFout->pDEV)->sName, pFout->sName); fflush(stdout); i = 0; strcpy(busy, "-\\|/"); while ( (buflen = fread(buf, 1, BUFSIZE, pFin)) != 0 ) { do { printf("\b%c", busy[i]); i = ++i & 3; fflush(stdout); len = MIN(buflen,SECTOR); if (msfwrite(buf, 1, len, pFout) != len) Fail(pFout->sName); buflen -= len; } while (buflen > 0); } printf("\b \n"); if (msfclose(pFout) != 0) Fail(pFout->sName); } Fail(s) char *s; { msperror(s); exit(EXIT_FAILURE); }