From 06aeb6c417dd9d113949714486a6e6337ef70b97 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Fri, 25 Aug 2000 03:50:10 +0000 Subject: ar.c now uses a linked list to process headers, uses getopt, new internal function extractAr(srcFD, dstFd, filename) to make it easily accessable to other busybox functions. moved copySubFile from ar.c to utilities.c modified dd.c to use fullWrite modified copyFile in utilities.c to use copySubFile --- coreutils/dd.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'coreutils/dd.c') diff --git a/coreutils/dd.c b/coreutils/dd.c index 6df2588..787e5da 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -44,7 +44,6 @@ extern int dd_main(int argc, char **argv) { char *inFile = NULL; char *outFile = NULL; - char *cp; int inFd; int outFd; int inCc = 0; @@ -135,42 +134,14 @@ extern int dd_main(int argc, char **argv) lseek(inFd, skipBlocks * blockSize, SEEK_SET); lseek(outFd, seekBlocks * blockSize, SEEK_SET); - // - //TODO: Convert to using fullRead & fullWrite - // from utility.c - // -Erik - while (outTotal < count * blockSize) { - inCc = read(inFd, buf, blockSize); - if (inCc < 0) { - perror(inFile); - goto cleanup; - } else if (inCc == 0) { - goto cleanup; - } - intotal += inCc; - cp = buf; - - while (intotal > outTotal) { - if (outTotal + inCc > count * blockSize) - inCc = count * blockSize - outTotal; - outCc = write(outFd, cp, inCc); - if (outCc < 0) { - perror(outFile); - goto cleanup; - } else if (outCc == 0) { - goto cleanup; - } - - inCc -= outCc; - cp += outCc; - outTotal += outCc; - } - } - if (inCc < 0) - perror(inFile); + while ((inCc = read(inFd, buf, sizeof(buf))) > 0) { + intotal +=inCc; + if ((outCc = fullWrite(outFd, buf, inCc)) < 0) + break; + outTotal += outCc; + } - cleanup: /* Note that we are not freeing memory or closing * files here, to save a few bytes. */ #ifdef BB_FEATURE_CLEAN_UP -- cgit v1.1