blob: 33711fa5ba9b2b8f1ba8bfa06fbcdb7c1bfbc7be [file] [log] [blame]
Adam Lesinski282e1812014-01-23 18:17:42 -08001//
2// Copyright 2006 The Android Open Source Project
3//
4// Android Asset Packaging Tool main entry point.
5//
6#include "Main.h"
7#include "Bundle.h"
8
9#include <utils/Log.h>
10#include <utils/threads.h>
11#include <utils/List.h>
12#include <utils/Errors.h>
13
14#include <stdlib.h>
15#include <getopt.h>
16#include <assert.h>
17
18using namespace android;
19
20static const char* gProgName = "aapt";
21
22/*
23 * When running under Cygwin on Windows, this will convert slash-based
24 * paths into back-slash-based ones. Otherwise the ApptAssets file comparisons
25 * fail later as they use back-slash separators under Windows.
26 *
27 * This operates in-place on the path string.
28 */
29void convertPath(char *path) {
30 if (path != NULL && OS_PATH_SEPARATOR != '/') {
31 for (; *path; path++) {
32 if (*path == '/') {
33 *path = OS_PATH_SEPARATOR;
34 }
35 }
36 }
37}
38
39/*
40 * Print usage info.
41 */
42void usage(void)
43{
44 fprintf(stderr, "Android Asset Packaging Tool\n\n");
45 fprintf(stderr, "Usage:\n");
46 fprintf(stderr,
47 " %s l[ist] [-v] [-a] file.{zip,jar,apk}\n"
48 " List contents of Zip-compatible archive.\n\n", gProgName);
49 fprintf(stderr,
50 " %s d[ump] [--values] [--include-meta-data] WHAT file.{apk} [asset [asset ...]]\n"
51 " strings Print the contents of the resource table string pool in the APK.\n"
52 " badging Print the label and icon for the app declared in APK.\n"
53 " permissions Print the permissions from the APK.\n"
54 " resources Print the resource table from the APK.\n"
55 " configurations Print the configurations in the APK.\n"
56 " xmltree Print the compiled xmls in the given assets.\n"
57 " xmlstrings Print the strings of the given compiled xml assets.\n\n", gProgName);
58 fprintf(stderr,
59 " %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\n"
60 " [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n"
61 " [--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
62 " [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \\\n"
63 " [--rename-manifest-package PACKAGE] \\\n"
64 " [--rename-instrumentation-target-package PACKAGE] \\\n"
65 " [--utf16] [--auto-add-overlay] \\\n"
66 " [--max-res-version VAL] \\\n"
67 " [-I base-package [-I base-package ...]] \\\n"
68 " [-A asset-source-dir] [-G class-list-file] [-P public-definitions-file] \\\n"
69 " [-S resource-sources [-S resource-sources ...]] \\\n"
70 " [-F apk-file] [-J R-file-dir] \\\n"
71 " [--product product1,product2,...] \\\n"
72 " [-c CONFIGS] [--preferred-configurations CONFIGS] \\\n"
73 " [raw-files-dir [raw-files-dir] ...] \\\n"
74 " [--output-text-symbols DIR]\n"
75 "\n"
76 " Package the android resources. It will read assets and resources that are\n"
77 " supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R\n"
78 " options control which files are output.\n\n"
79 , gProgName);
80 fprintf(stderr,
81 " %s r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...]\n"
82 " Delete specified files from Zip-compatible archive.\n\n",
83 gProgName);
84 fprintf(stderr,
85 " %s a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]\n"
86 " Add specified files to Zip-compatible archive.\n\n", gProgName);
87 fprintf(stderr,
88 " %s c[runch] [-v] -S resource-sources ... -C output-folder ...\n"
89 " Do PNG preprocessing on one or several resource folders\n"
90 " and store the results in the output folder.\n\n", gProgName);
91 fprintf(stderr,
92 " %s s[ingleCrunch] [-v] -i input-file -o outputfile\n"
93 " Do PNG preprocessing on a single file.\n\n", gProgName);
94 fprintf(stderr,
95 " %s v[ersion]\n"
96 " Print program version.\n\n", gProgName);
97 fprintf(stderr,
98 " Modifiers:\n"
99 " -a print Android-specific data (resources, manifest) when listing\n"
100 " -c specify which configurations to include. The default is all\n"
101 " configurations. The value of the parameter should be a comma\n"
102 " separated list of configuration values. Locales should be specified\n"
103 " as either a language or language-region pair. Some examples:\n"
104 " en\n"
105 " port,en\n"
106 " port,land,en_US\n"
107 " If you put the special locale, zz_ZZ on the list, it will perform\n"
108 " pseudolocalization on the default locale, modifying all of the\n"
109 " strings so you can look for strings that missed the\n"
110 " internationalization process. For example:\n"
111 " port,land,zz_ZZ\n"
112 " -d one or more device assets to include, separated by commas\n"
113 " -f force overwrite of existing files\n"
114 " -g specify a pixel tolerance to force images to grayscale, default 0\n"
115 " -j specify a jar or zip file containing classes to include\n"
116 " -k junk path of file(s) added\n"
117 " -m make package directories under location specified by -J\n"
118#if 0
119 " -p pseudolocalize the default configuration\n"
120#endif
121 " -u update existing packages (add new, replace older, remove deleted files)\n"
122 " -v verbose output\n"
123 " -x create extending (non-application) resource IDs\n"
124 " -z require localization of resource attributes marked with\n"
125 " localization=\"suggested\"\n"
126 " -A additional directory in which to find raw asset files\n"
127 " -G A file to output proguard options into.\n"
128 " -F specify the apk file to output\n"
129 " -I add an existing package to base include set\n"
130 " -J specify where to output R.java resource constant definitions\n"
131 " -M specify full path to AndroidManifest.xml to include in zip\n"
132 " -P specify where to output public resource definitions\n"
133 " -S directory in which to find resources. Multiple directories will be scanned\n"
134 " and the first match found (left to right) will take precedence.\n"
135 " -0 specifies an additional extension for which such files will not\n"
136 " be stored compressed in the .apk. An empty string means to not\n"
137 " compress any files at all.\n"
138 " --debug-mode\n"
139 " inserts android:debuggable=\"true\" in to the application node of the\n"
140 " manifest, making the application debuggable even on production devices.\n"
141 " --include-meta-data\n"
142 " when used with \"dump badging\" also includes meta-data tags.\n"
143 " --min-sdk-version\n"
144 " inserts android:minSdkVersion in to manifest. If the version is 7 or\n"
145 " higher, the default encoding for resources will be in UTF-8.\n"
146 " --target-sdk-version\n"
147 " inserts android:targetSdkVersion in to manifest.\n"
148 " --max-res-version\n"
149 " ignores versioned resource directories above the given value.\n"
150 " --values\n"
151 " when used with \"dump resources\" also includes resource values.\n"
152 " --version-code\n"
153 " inserts android:versionCode in to manifest.\n"
154 " --version-name\n"
155 " inserts android:versionName in to manifest.\n"
Jeff Davidsondf08d1c2014-02-25 12:28:08 -0800156 " --replace-version\n"
157 " If --version-code and/or --version-name are specified, these\n"
158 " values will replace any value already in the manifest. By\n"
159 " default, nothing is changed if the manifest already defines\n"
160 " these attributes.\n"
Adam Lesinski282e1812014-01-23 18:17:42 -0800161 " --custom-package\n"
162 " generates R.java into a different package.\n"
163 " --extra-packages\n"
164 " generate R.java for libraries. Separate libraries with ':'.\n"
165 " --generate-dependencies\n"
166 " generate dependency files in the same directories for R.java and resource package\n"
167 " --auto-add-overlay\n"
168 " Automatically add resources that are only in overlays.\n"
169 " --preferred-configurations\n"
170 " Like the -c option for filtering out unneeded configurations, but\n"
171 " only expresses a preference. If there is no resource available with\n"
172 " the preferred configuration then it will not be stripped.\n"
173 " --rename-manifest-package\n"
174 " Rewrite the manifest so that its package name is the package name\n"
175 " given here. Relative class names (for example .Foo) will be\n"
176 " changed to absolute names with the old package so that the code\n"
177 " does not need to change.\n"
178 " --rename-instrumentation-target-package\n"
179 " Rewrite the manifest so that all of its instrumentation\n"
180 " components target the given package. Useful when used in\n"
181 " conjunction with --rename-manifest-package to fix tests against\n"
182 " a package that has been renamed.\n"
183 " --product\n"
184 " Specifies which variant to choose for strings that have\n"
185 " product variants\n"
186 " --utf16\n"
187 " changes default encoding for resources to UTF-16. Only useful when API\n"
188 " level is set to 7 or higher where the default encoding is UTF-8.\n"
189 " --non-constant-id\n"
190 " Make the resources ID non constant. This is required to make an R java class\n"
191 " that does not contain the final value but is used to make reusable compiled\n"
192 " libraries that need to access resources.\n"
193 " --error-on-failed-insert\n"
194 " Forces aapt to return an error if it fails to insert values into the manifest\n"
195 " with --debug-mode, --min-sdk-version, --target-sdk-version --version-code\n"
196 " and --version-name.\n"
197 " Insertion typically fails if the manifest already defines the attribute.\n"
Ying Wangcd28bd32013-11-14 17:12:10 -0800198 " --error-on-missing-config-entry\n"
199 " Forces aapt to return an error if it fails to find an entry for a configuration.\n"
Adam Lesinski282e1812014-01-23 18:17:42 -0800200 " --output-text-symbols\n"
201 " Generates a text file containing the resource symbols of the R class in the\n"
202 " specified folder.\n"
203 " --ignore-assets\n"
204 " Assets to be ignored. Default pattern is:\n"
205 " %s\n",
206 gDefaultIgnoreAssets);
207}
208
209/*
210 * Dispatch the command.
211 */
212int handleCommand(Bundle* bundle)
213{
214 //printf("--- command %d (verbose=%d force=%d):\n",
215 // bundle->getCommand(), bundle->getVerbose(), bundle->getForce());
216 //for (int i = 0; i < bundle->getFileSpecCount(); i++)
217 // printf(" %d: '%s'\n", i, bundle->getFileSpecEntry(i));
218
219 switch (bundle->getCommand()) {
220 case kCommandVersion: return doVersion(bundle);
221 case kCommandList: return doList(bundle);
222 case kCommandDump: return doDump(bundle);
223 case kCommandAdd: return doAdd(bundle);
224 case kCommandRemove: return doRemove(bundle);
225 case kCommandPackage: return doPackage(bundle);
226 case kCommandCrunch: return doCrunch(bundle);
227 case kCommandSingleCrunch: return doSingleCrunch(bundle);
228 default:
229 fprintf(stderr, "%s: requested command not yet supported\n", gProgName);
230 return 1;
231 }
232}
233
234/*
235 * Parse args.
236 */
237int main(int argc, char* const argv[])
238{
239 char *prog = argv[0];
240 Bundle bundle;
241 bool wantUsage = false;
242 int result = 1; // pessimistically assume an error.
243 int tolerance = 0;
244
245 /* default to compression */
246 bundle.setCompressionMethod(ZipEntry::kCompressDeflated);
247
248 if (argc < 2) {
249 wantUsage = true;
250 goto bail;
251 }
252
253 if (argv[1][0] == 'v')
254 bundle.setCommand(kCommandVersion);
255 else if (argv[1][0] == 'd')
256 bundle.setCommand(kCommandDump);
257 else if (argv[1][0] == 'l')
258 bundle.setCommand(kCommandList);
259 else if (argv[1][0] == 'a')
260 bundle.setCommand(kCommandAdd);
261 else if (argv[1][0] == 'r')
262 bundle.setCommand(kCommandRemove);
263 else if (argv[1][0] == 'p')
264 bundle.setCommand(kCommandPackage);
265 else if (argv[1][0] == 'c')
266 bundle.setCommand(kCommandCrunch);
267 else if (argv[1][0] == 's')
268 bundle.setCommand(kCommandSingleCrunch);
269 else {
270 fprintf(stderr, "ERROR: Unknown command '%s'\n", argv[1]);
271 wantUsage = true;
272 goto bail;
273 }
274 argc -= 2;
275 argv += 2;
276
277 /*
278 * Pull out flags. We support "-fv" and "-f -v".
279 */
280 while (argc && argv[0][0] == '-') {
281 /* flag(s) found */
282 const char* cp = argv[0] +1;
283
284 while (*cp != '\0') {
285 switch (*cp) {
286 case 'v':
287 bundle.setVerbose(true);
288 break;
289 case 'a':
290 bundle.setAndroidList(true);
291 break;
292 case 'c':
293 argc--;
294 argv++;
295 if (!argc) {
296 fprintf(stderr, "ERROR: No argument supplied for '-c' option\n");
297 wantUsage = true;
298 goto bail;
299 }
300 bundle.addConfigurations(argv[0]);
301 break;
302 case 'f':
303 bundle.setForce(true);
304 break;
305 case 'g':
306 argc--;
307 argv++;
308 if (!argc) {
309 fprintf(stderr, "ERROR: No argument supplied for '-g' option\n");
310 wantUsage = true;
311 goto bail;
312 }
313 tolerance = atoi(argv[0]);
314 bundle.setGrayscaleTolerance(tolerance);
315 printf("%s: Images with deviation <= %d will be forced to grayscale.\n", prog, tolerance);
316 break;
317 case 'k':
318 bundle.setJunkPath(true);
319 break;
320 case 'm':
321 bundle.setMakePackageDirs(true);
322 break;
323#if 0
324 case 'p':
325 bundle.setPseudolocalize(true);
326 break;
327#endif
328 case 'u':
329 bundle.setUpdate(true);
330 break;
331 case 'x':
332 bundle.setExtending(true);
333 break;
334 case 'z':
335 bundle.setRequireLocalization(true);
336 break;
337 case 'j':
338 argc--;
339 argv++;
340 if (!argc) {
341 fprintf(stderr, "ERROR: No argument supplied for '-j' option\n");
342 wantUsage = true;
343 goto bail;
344 }
345 convertPath(argv[0]);
346 bundle.addJarFile(argv[0]);
347 break;
348 case 'A':
349 argc--;
350 argv++;
351 if (!argc) {
352 fprintf(stderr, "ERROR: No argument supplied for '-A' option\n");
353 wantUsage = true;
354 goto bail;
355 }
356 convertPath(argv[0]);
Adam Lesinski09384302014-01-22 16:07:42 -0800357 bundle.addAssetSourceDir(argv[0]);
Adam Lesinski282e1812014-01-23 18:17:42 -0800358 break;
359 case 'G':
360 argc--;
361 argv++;
362 if (!argc) {
363 fprintf(stderr, "ERROR: No argument supplied for '-G' option\n");
364 wantUsage = true;
365 goto bail;
366 }
367 convertPath(argv[0]);
368 bundle.setProguardFile(argv[0]);
369 break;
370 case 'I':
371 argc--;
372 argv++;
373 if (!argc) {
374 fprintf(stderr, "ERROR: No argument supplied for '-I' option\n");
375 wantUsage = true;
376 goto bail;
377 }
378 convertPath(argv[0]);
379 bundle.addPackageInclude(argv[0]);
380 break;
381 case 'F':
382 argc--;
383 argv++;
384 if (!argc) {
385 fprintf(stderr, "ERROR: No argument supplied for '-F' option\n");
386 wantUsage = true;
387 goto bail;
388 }
389 convertPath(argv[0]);
390 bundle.setOutputAPKFile(argv[0]);
391 break;
392 case 'J':
393 argc--;
394 argv++;
395 if (!argc) {
396 fprintf(stderr, "ERROR: No argument supplied for '-J' option\n");
397 wantUsage = true;
398 goto bail;
399 }
400 convertPath(argv[0]);
401 bundle.setRClassDir(argv[0]);
402 break;
403 case 'M':
404 argc--;
405 argv++;
406 if (!argc) {
407 fprintf(stderr, "ERROR: No argument supplied for '-M' option\n");
408 wantUsage = true;
409 goto bail;
410 }
411 convertPath(argv[0]);
412 bundle.setAndroidManifestFile(argv[0]);
413 break;
414 case 'P':
415 argc--;
416 argv++;
417 if (!argc) {
418 fprintf(stderr, "ERROR: No argument supplied for '-P' option\n");
419 wantUsage = true;
420 goto bail;
421 }
422 convertPath(argv[0]);
423 bundle.setPublicOutputFile(argv[0]);
424 break;
425 case 'S':
426 argc--;
427 argv++;
428 if (!argc) {
429 fprintf(stderr, "ERROR: No argument supplied for '-S' option\n");
430 wantUsage = true;
431 goto bail;
432 }
433 convertPath(argv[0]);
434 bundle.addResourceSourceDir(argv[0]);
435 break;
436 case 'C':
437 argc--;
438 argv++;
439 if (!argc) {
440 fprintf(stderr, "ERROR: No argument supplied for '-C' option\n");
441 wantUsage = true;
442 goto bail;
443 }
444 convertPath(argv[0]);
445 bundle.setCrunchedOutputDir(argv[0]);
446 break;
447 case 'i':
448 argc--;
449 argv++;
450 if (!argc) {
451 fprintf(stderr, "ERROR: No argument supplied for '-i' option\n");
452 wantUsage = true;
453 goto bail;
454 }
455 convertPath(argv[0]);
456 bundle.setSingleCrunchInputFile(argv[0]);
457 break;
458 case 'o':
459 argc--;
460 argv++;
461 if (!argc) {
462 fprintf(stderr, "ERROR: No argument supplied for '-o' option\n");
463 wantUsage = true;
464 goto bail;
465 }
466 convertPath(argv[0]);
467 bundle.setSingleCrunchOutputFile(argv[0]);
468 break;
469 case '0':
470 argc--;
471 argv++;
472 if (!argc) {
473 fprintf(stderr, "ERROR: No argument supplied for '-e' option\n");
474 wantUsage = true;
475 goto bail;
476 }
477 if (argv[0][0] != 0) {
478 bundle.addNoCompressExtension(argv[0]);
479 } else {
480 bundle.setCompressionMethod(ZipEntry::kCompressStored);
481 }
482 break;
483 case '-':
484 if (strcmp(cp, "-debug-mode") == 0) {
485 bundle.setDebugMode(true);
486 } else if (strcmp(cp, "-min-sdk-version") == 0) {
487 argc--;
488 argv++;
489 if (!argc) {
490 fprintf(stderr, "ERROR: No argument supplied for '--min-sdk-version' option\n");
491 wantUsage = true;
492 goto bail;
493 }
494 bundle.setMinSdkVersion(argv[0]);
495 } else if (strcmp(cp, "-target-sdk-version") == 0) {
496 argc--;
497 argv++;
498 if (!argc) {
499 fprintf(stderr, "ERROR: No argument supplied for '--target-sdk-version' option\n");
500 wantUsage = true;
501 goto bail;
502 }
503 bundle.setTargetSdkVersion(argv[0]);
504 } else if (strcmp(cp, "-max-sdk-version") == 0) {
505 argc--;
506 argv++;
507 if (!argc) {
508 fprintf(stderr, "ERROR: No argument supplied for '--max-sdk-version' option\n");
509 wantUsage = true;
510 goto bail;
511 }
512 bundle.setMaxSdkVersion(argv[0]);
513 } else if (strcmp(cp, "-max-res-version") == 0) {
514 argc--;
515 argv++;
516 if (!argc) {
517 fprintf(stderr, "ERROR: No argument supplied for '--max-res-version' option\n");
518 wantUsage = true;
519 goto bail;
520 }
521 bundle.setMaxResVersion(argv[0]);
522 } else if (strcmp(cp, "-version-code") == 0) {
523 argc--;
524 argv++;
525 if (!argc) {
526 fprintf(stderr, "ERROR: No argument supplied for '--version-code' option\n");
527 wantUsage = true;
528 goto bail;
529 }
530 bundle.setVersionCode(argv[0]);
531 } else if (strcmp(cp, "-version-name") == 0) {
532 argc--;
533 argv++;
534 if (!argc) {
535 fprintf(stderr, "ERROR: No argument supplied for '--version-name' option\n");
536 wantUsage = true;
537 goto bail;
538 }
539 bundle.setVersionName(argv[0]);
Jeff Davidsondf08d1c2014-02-25 12:28:08 -0800540 } else if (strcmp(cp, "-replace-version") == 0) {
541 bundle.setReplaceVersion(true);
Adam Lesinski282e1812014-01-23 18:17:42 -0800542 } else if (strcmp(cp, "-values") == 0) {
543 bundle.setValues(true);
544 } else if (strcmp(cp, "-include-meta-data") == 0) {
545 bundle.setIncludeMetaData(true);
546 } else if (strcmp(cp, "-custom-package") == 0) {
547 argc--;
548 argv++;
549 if (!argc) {
550 fprintf(stderr, "ERROR: No argument supplied for '--custom-package' option\n");
551 wantUsage = true;
552 goto bail;
553 }
554 bundle.setCustomPackage(argv[0]);
555 } else if (strcmp(cp, "-extra-packages") == 0) {
556 argc--;
557 argv++;
558 if (!argc) {
559 fprintf(stderr, "ERROR: No argument supplied for '--extra-packages' option\n");
560 wantUsage = true;
561 goto bail;
562 }
563 bundle.setExtraPackages(argv[0]);
564 } else if (strcmp(cp, "-generate-dependencies") == 0) {
565 bundle.setGenDependencies(true);
566 } else if (strcmp(cp, "-utf16") == 0) {
567 bundle.setWantUTF16(true);
568 } else if (strcmp(cp, "-preferred-configurations") == 0) {
569 argc--;
570 argv++;
571 if (!argc) {
572 fprintf(stderr, "ERROR: No argument supplied for '--preferred-configurations' option\n");
573 wantUsage = true;
574 goto bail;
575 }
576 bundle.addPreferredConfigurations(argv[0]);
577 } else if (strcmp(cp, "-rename-manifest-package") == 0) {
578 argc--;
579 argv++;
580 if (!argc) {
581 fprintf(stderr, "ERROR: No argument supplied for '--rename-manifest-package' option\n");
582 wantUsage = true;
583 goto bail;
584 }
585 bundle.setManifestPackageNameOverride(argv[0]);
586 } else if (strcmp(cp, "-rename-instrumentation-target-package") == 0) {
587 argc--;
588 argv++;
589 if (!argc) {
590 fprintf(stderr, "ERROR: No argument supplied for '--rename-instrumentation-target-package' option\n");
591 wantUsage = true;
592 goto bail;
593 }
594 bundle.setInstrumentationPackageNameOverride(argv[0]);
595 } else if (strcmp(cp, "-auto-add-overlay") == 0) {
596 bundle.setAutoAddOverlay(true);
597 } else if (strcmp(cp, "-error-on-failed-insert") == 0) {
598 bundle.setErrorOnFailedInsert(true);
Ying Wangcd28bd32013-11-14 17:12:10 -0800599 } else if (strcmp(cp, "-error-on-missing-config-entry") == 0) {
600 bundle.setErrorOnMissingConfigEntry(true);
Adam Lesinski282e1812014-01-23 18:17:42 -0800601 } else if (strcmp(cp, "-output-text-symbols") == 0) {
602 argc--;
603 argv++;
604 if (!argc) {
605 fprintf(stderr, "ERROR: No argument supplied for '-output-text-symbols' option\n");
606 wantUsage = true;
607 goto bail;
608 }
609 bundle.setOutputTextSymbols(argv[0]);
610 } else if (strcmp(cp, "-product") == 0) {
611 argc--;
612 argv++;
613 if (!argc) {
614 fprintf(stderr, "ERROR: No argument supplied for '--product' option\n");
615 wantUsage = true;
616 goto bail;
617 }
618 bundle.setProduct(argv[0]);
619 } else if (strcmp(cp, "-non-constant-id") == 0) {
620 bundle.setNonConstantId(true);
621 } else if (strcmp(cp, "-no-crunch") == 0) {
622 bundle.setUseCrunchCache(true);
623 } else if (strcmp(cp, "-ignore-assets") == 0) {
624 argc--;
625 argv++;
626 if (!argc) {
627 fprintf(stderr, "ERROR: No argument supplied for '--ignore-assets' option\n");
628 wantUsage = true;
629 goto bail;
630 }
631 gUserIgnoreAssets = argv[0];
632 } else {
633 fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp);
634 wantUsage = true;
635 goto bail;
636 }
637 cp += strlen(cp) - 1;
638 break;
639 default:
640 fprintf(stderr, "ERROR: Unknown flag '-%c'\n", *cp);
641 wantUsage = true;
642 goto bail;
643 }
644
645 cp++;
646 }
647 argc--;
648 argv++;
649 }
650
651 /*
652 * We're past the flags. The rest all goes straight in.
653 */
654 bundle.setFileSpec(argv, argc);
655
656 result = handleCommand(&bundle);
657
658bail:
659 if (wantUsage) {
660 usage();
661 result = 2;
662 }
663
664 //printf("--> returning %d\n", result);
665 return result;
666}