/* * MS2RT1.C Program to copy files from 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[]; { MSFILE *pFin; FILE *pFout; int len; int buflen; int fDone; int i; char busy[5]; if (argc != 3) { printf("Usage: MS2RT1 dev:msfilespec [dev:]rtfilespec"); } if ((pFin = msfopen(argv[1], "rb")) == NULL) Fail(argv[1]); if ((pFout = fopen(argv[2], "wn")) == NULL) Fail(argv[2]); printf("Copying %s:%s to %s ", ((MSDEV *)pFin->pDEV)->sName, pFin->sName, pFout->io_name); i = 0; strcpy(busy, "-\\|/"); fDone = FALSE; while (!fDone) { buflen = 0; do { len = msfread(&buf[buflen], 1, SECTOR, pFin); if (len == 0) fDone = TRUE; buflen += len; printf("\b%c", busy[i]); i = ++i & 3; fflush(stdout); } while ( (buflen < BUFSIZE) && (len != 0)); if (fwrite(buf, 1, buflen, pFout) != buflen) Fail(pFout->io_name); } printf("\b \n"); if (fclose(pFout) != 0) Fail(argv[2]); } Fail(s) char *s; { msperror(s); exit(EXIT_FAILURE); }