From b2f46576b8f693505638502e88a065c6e84b927d Mon Sep 17 00:00:00 2001 From: bug1 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 git-svn-id: svn://busybox.net/trunk/busybox@983 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- dd.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'dd.c') diff --git a/dd.c b/dd.c index 6df2588ca..787e5da95 100644 --- a/dd.c +++ b/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.2.3-55-g6feb