diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-08-25 03:50:10 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-08-25 03:50:10 +0000 |
commit | b2f46576b8f693505638502e88a065c6e84b927d (patch) | |
tree | 0f002c36314483775fa2a248ae1c8b5346c70030 /dd.c | |
parent | dc5f751284b2733b470fa6d2816c60d192a16fbc (diff) | |
download | busybox-w32-b2f46576b8f693505638502e88a065c6e84b927d.tar.gz busybox-w32-b2f46576b8f693505638502e88a065c6e84b927d.tar.bz2 busybox-w32-b2f46576b8f693505638502e88a065c6e84b927d.zip |
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
Diffstat (limited to 'dd.c')
-rw-r--r-- | dd.c | 41 |
1 files changed, 6 insertions, 35 deletions
@@ -44,7 +44,6 @@ extern int dd_main(int argc, char **argv) | |||
44 | { | 44 | { |
45 | char *inFile = NULL; | 45 | char *inFile = NULL; |
46 | char *outFile = NULL; | 46 | char *outFile = NULL; |
47 | char *cp; | ||
48 | int inFd; | 47 | int inFd; |
49 | int outFd; | 48 | int outFd; |
50 | int inCc = 0; | 49 | int inCc = 0; |
@@ -135,42 +134,14 @@ extern int dd_main(int argc, char **argv) | |||
135 | 134 | ||
136 | lseek(inFd, skipBlocks * blockSize, SEEK_SET); | 135 | lseek(inFd, skipBlocks * blockSize, SEEK_SET); |
137 | lseek(outFd, seekBlocks * blockSize, SEEK_SET); | 136 | lseek(outFd, seekBlocks * blockSize, SEEK_SET); |
138 | // | ||
139 | //TODO: Convert to using fullRead & fullWrite | ||
140 | // from utility.c | ||
141 | // -Erik | ||
142 | while (outTotal < count * blockSize) { | ||
143 | inCc = read(inFd, buf, blockSize); | ||
144 | if (inCc < 0) { | ||
145 | perror(inFile); | ||
146 | goto cleanup; | ||
147 | } else if (inCc == 0) { | ||
148 | goto cleanup; | ||
149 | } | ||
150 | intotal += inCc; | ||
151 | cp = buf; | ||
152 | |||
153 | while (intotal > outTotal) { | ||
154 | if (outTotal + inCc > count * blockSize) | ||
155 | inCc = count * blockSize - outTotal; | ||
156 | outCc = write(outFd, cp, inCc); | ||
157 | if (outCc < 0) { | ||
158 | perror(outFile); | ||
159 | goto cleanup; | ||
160 | } else if (outCc == 0) { | ||
161 | goto cleanup; | ||
162 | } | ||
163 | |||
164 | inCc -= outCc; | ||
165 | cp += outCc; | ||
166 | outTotal += outCc; | ||
167 | } | ||
168 | } | ||
169 | 137 | ||
170 | if (inCc < 0) | 138 | while ((inCc = read(inFd, buf, sizeof(buf))) > 0) { |
171 | perror(inFile); | 139 | intotal +=inCc; |
140 | if ((outCc = fullWrite(outFd, buf, inCc)) < 0) | ||
141 | break; | ||
142 | outTotal += outCc; | ||
143 | } | ||
172 | 144 | ||
173 | cleanup: | ||
174 | /* Note that we are not freeing memory or closing | 145 | /* Note that we are not freeing memory or closing |
175 | * files here, to save a few bytes. */ | 146 | * files here, to save a few bytes. */ |
176 | #ifdef BB_FEATURE_CLEAN_UP | 147 | #ifdef BB_FEATURE_CLEAN_UP |