Remove support for truncating names in archives.
[oota-llvm.git] / tools / llvm-ar / llvm-ar.cpp
1 //===-- llvm-ar.cpp - LLVM archive librarian utility ----------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Builds up (relatively) standard unix archive files (.a) containing LLVM
11 // bitcode or other files.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "Archive.h"
16 #include "llvm/IR/LLVMContext.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/Support/CommandLine.h"
19 #include "llvm/Support/FileSystem.h"
20 #include "llvm/Support/Format.h"
21 #include "llvm/Support/ManagedStatic.h"
22 #include "llvm/Support/PrettyStackTrace.h"
23 #include "llvm/Support/Signals.h"
24 #include "llvm/Support/raw_ostream.h"
25 #include <algorithm>
26 #include <cstdlib>
27 #include <fcntl.h>
28 #include <memory>
29
30 #if !defined(_MSC_VER) && !defined(__MINGW32__)
31 #include <unistd.h>
32 #else
33 #include <io.h>
34 #endif
35
36 using namespace llvm;
37
38 // Option for compatibility with AIX, not used but must allow it to be present.
39 static cl::opt<bool>
40 X32Option ("X32_64", cl::Hidden,
41             cl::desc("Ignored option for compatibility with AIX"));
42
43 // llvm-ar operation code and modifier flags. This must come first.
44 static cl::opt<std::string>
45 Options(cl::Positional, cl::Required, cl::desc("{operation}[modifiers]..."));
46
47 // llvm-ar remaining positional arguments.
48 static cl::list<std::string>
49 RestOfArgs(cl::Positional, cl::OneOrMore,
50     cl::desc("[relpos] [count] <archive-file> [members]..."));
51
52 // MoreHelp - Provide additional help output explaining the operations and
53 // modifiers of llvm-ar. This object instructs the CommandLine library
54 // to print the text of the constructor when the --help option is given.
55 static cl::extrahelp MoreHelp(
56   "\nOPERATIONS:\n"
57   "  d[NsS]       - delete file(s) from the archive\n"
58   "  m[abiSs]     - move file(s) in the archive\n"
59   "  p[kN]        - print file(s) found in the archive\n"
60   "  q[ufsS]      - quick append file(s) to the archive\n"
61   "  r[abfiuRsS]  - replace or insert file(s) into the archive\n"
62   "  t            - display contents of archive\n"
63   "  x[No]        - extract file(s) from the archive\n"
64   "\nMODIFIERS (operation specific):\n"
65   "  [a] - put file(s) after [relpos]\n"
66   "  [b] - put file(s) before [relpos] (same as [i])\n"
67   "  [i] - put file(s) before [relpos] (same as [b])\n"
68   "  [N] - use instance [count] of name\n"
69   "  [o] - preserve original dates\n"
70   "  [P] - use full path names when matching\n"
71   "  [s] - create an archive index (cf. ranlib)\n"
72   "  [S] - do not build a symbol table\n"
73   "  [u] - update only files newer than archive contents\n"
74   "\nMODIFIERS (generic):\n"
75   "  [c] - do not warn if the library had to be created\n"
76   "  [v] - be verbose about actions taken\n"
77 );
78
79 // This enumeration delineates the kinds of operations on an archive
80 // that are permitted.
81 enum ArchiveOperation {
82   Print,            ///< Print the contents of the archive
83   Delete,           ///< Delete the specified members
84   Move,             ///< Move members to end or as given by {a,b,i} modifiers
85   QuickAppend,      ///< Quickly append to end of archive
86   ReplaceOrInsert,  ///< Replace or Insert members
87   DisplayTable,     ///< Display the table of contents
88   Extract           ///< Extract files back to file system
89 };
90
91 // Modifiers to follow operation to vary behavior
92 bool AddAfter = false;           ///< 'a' modifier
93 bool AddBefore = false;          ///< 'b' modifier
94 bool Create = false;             ///< 'c' modifier
95 bool InsertBefore = false;       ///< 'i' modifier
96 bool UseCount = false;           ///< 'N' modifier
97 bool OriginalDates = false;      ///< 'o' modifier
98 bool FullPath = false;           ///< 'P' modifier
99 bool SymTable = true;            ///< 's' & 'S' modifiers
100 bool OnlyUpdate = false;         ///< 'u' modifier
101 bool Verbose = false;            ///< 'v' modifier
102
103 // Relative Positional Argument (for insert/move). This variable holds
104 // the name of the archive member to which the 'a', 'b' or 'i' modifier
105 // refers. Only one of 'a', 'b' or 'i' can be specified so we only need
106 // one variable.
107 std::string RelPos;
108
109 // Select which of multiple entries in the archive with the same name should be
110 // used (specified with -N) for the delete and extract operations.
111 int Count = 1;
112
113 // This variable holds the name of the archive file as given on the
114 // command line.
115 std::string ArchiveName;
116
117 // This variable holds the list of member files to proecess, as given
118 // on the command line.
119 std::vector<std::string> Members;
120
121 // This variable holds the (possibly expanded) list of path objects that
122 // correspond to files we will
123 std::set<std::string> Paths;
124
125 // The Archive object to which all the editing operations will be sent.
126 Archive* TheArchive = 0;
127
128 // The name this program was invoked as.
129 static const char *program_name;
130
131 // show_help - Show the error message, the help message and exit.
132 LLVM_ATTRIBUTE_NORETURN static void
133 show_help(const std::string &msg) {
134   errs() << program_name << ": " << msg << "\n\n";
135   cl::PrintHelpMessage();
136   if (TheArchive)
137     delete TheArchive;
138   std::exit(1);
139 }
140
141 // fail - Show the error message and exit.
142 LLVM_ATTRIBUTE_NORETURN static void
143 fail(const std::string &msg) {
144   errs() << program_name << ": " << msg << "\n\n";
145   if (TheArchive)
146     delete TheArchive;
147   std::exit(1);
148 }
149
150 // getRelPos - Extract the member filename from the command line for
151 // the [relpos] argument associated with a, b, and i modifiers
152 void getRelPos() {
153   if(RestOfArgs.size() == 0)
154     show_help("Expected [relpos] for a, b, or i modifier");
155   RelPos = RestOfArgs[0];
156   RestOfArgs.erase(RestOfArgs.begin());
157 }
158
159 // getCount - Extract the [count] argument associated with the N modifier
160 // from the command line and check its value.
161 void getCount() {
162   if(RestOfArgs.size() == 0)
163     show_help("Expected [count] value with N modifier");
164
165   Count = atoi(RestOfArgs[0].c_str());
166   RestOfArgs.erase(RestOfArgs.begin());
167
168   // Non-positive counts are not allowed
169   if (Count < 1)
170     show_help("Invalid [count] value (not a positive integer)");
171 }
172
173 // getArchive - Get the archive file name from the command line
174 void getArchive() {
175   if(RestOfArgs.size() == 0)
176     show_help("An archive name must be specified");
177   ArchiveName = RestOfArgs[0];
178   RestOfArgs.erase(RestOfArgs.begin());
179 }
180
181 // getMembers - Copy over remaining items in RestOfArgs to our Members vector
182 // This is just for clarity.
183 void getMembers() {
184   if(RestOfArgs.size() > 0)
185     Members = std::vector<std::string>(RestOfArgs);
186 }
187
188 // parseCommandLine - Parse the command line options as presented and return the
189 // operation specified. Process all modifiers and check to make sure that
190 // constraints on modifier/operation pairs have not been violated.
191 ArchiveOperation parseCommandLine() {
192
193   // Keep track of number of operations. We can only specify one
194   // per execution.
195   unsigned NumOperations = 0;
196
197   // Keep track of the number of positional modifiers (a,b,i). Only
198   // one can be specified.
199   unsigned NumPositional = 0;
200
201   // Keep track of which operation was requested
202   ArchiveOperation Operation;
203
204   for(unsigned i=0; i<Options.size(); ++i) {
205     switch(Options[i]) {
206     case 'd': ++NumOperations; Operation = Delete; break;
207     case 'm': ++NumOperations; Operation = Move ; break;
208     case 'p': ++NumOperations; Operation = Print; break;
209     case 'q': ++NumOperations; Operation = QuickAppend; break;
210     case 'r': ++NumOperations; Operation = ReplaceOrInsert; break;
211     case 't': ++NumOperations; Operation = DisplayTable; break;
212     case 'x': ++NumOperations; Operation = Extract; break;
213     case 'c': Create = true; break;
214     case 'l': /* accepted but unused */ break;
215     case 'o': OriginalDates = true; break;
216     case 's': break; // Ignore for now.
217     case 'S': break; // Ignore for now.
218     case 'P': FullPath = true; break;
219     case 'u': OnlyUpdate = true; break;
220     case 'v': Verbose = true; break;
221     case 'a':
222       getRelPos();
223       AddAfter = true;
224       NumPositional++;
225       break;
226     case 'b':
227       getRelPos();
228       AddBefore = true;
229       NumPositional++;
230       break;
231     case 'i':
232       getRelPos();
233       InsertBefore = true;
234       NumPositional++;
235       break;
236     case 'N':
237       getCount();
238       UseCount = true;
239       break;
240     default:
241       cl::PrintHelpMessage();
242     }
243   }
244
245   // At this point, the next thing on the command line must be
246   // the archive name.
247   getArchive();
248
249   // Everything on the command line at this point is a member.
250   getMembers();
251
252   // Perform various checks on the operation/modifier specification
253   // to make sure we are dealing with a legal request.
254   if (NumOperations == 0)
255     show_help("You must specify at least one of the operations");
256   if (NumOperations > 1)
257     show_help("Only one operation may be specified");
258   if (NumPositional > 1)
259     show_help("You may only specify one of a, b, and i modifiers");
260   if (AddAfter || AddBefore || InsertBefore) {
261     if (Operation != Move && Operation != ReplaceOrInsert)
262       show_help("The 'a', 'b' and 'i' modifiers can only be specified with "
263             "the 'm' or 'r' operations");
264   }
265   if (OriginalDates && Operation != Extract)
266     show_help("The 'o' modifier is only applicable to the 'x' operation");
267   if (OnlyUpdate && Operation != ReplaceOrInsert)
268     show_help("The 'u' modifier is only applicable to the 'r' operation");
269   if (Count > 1 && Members.size() > 1)
270     show_help("Only one member name may be specified with the 'N' modifier");
271
272   // Return the parsed operation to the caller
273   return Operation;
274 }
275
276 // buildPaths - Convert the strings in the Members vector to sys::Path objects
277 // and make sure they are valid and exist exist. This check is only needed for
278 // the operations that add/replace files to the archive ('q' and 'r')
279 bool buildPaths(bool checkExistence, std::string* ErrMsg) {
280   for (unsigned i = 0; i < Members.size(); i++) {
281     std::string aPath = Members[i];
282     if (checkExistence) {
283       bool IsDirectory;
284       error_code EC = sys::fs::is_directory(aPath, IsDirectory);
285       if (EC)
286         fail(aPath + ": " + EC.message());
287       if (IsDirectory)
288         fail(aPath + " Is a directory");
289
290       Paths.insert(aPath);
291     } else {
292       Paths.insert(aPath);
293     }
294   }
295   return false;
296 }
297
298 // doPrint - Implements the 'p' operation. This function traverses the archive
299 // looking for members that match the path list. It is careful to uncompress
300 // things that should be and to skip bitcode files unless the 'k' modifier was
301 // given.
302 bool doPrint(std::string* ErrMsg) {
303   if (buildPaths(false, ErrMsg))
304     return true;
305   unsigned countDown = Count;
306   for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
307        I != E; ++I ) {
308     if (Paths.empty() ||
309         (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
310       if (countDown == 1) {
311         const char* data = reinterpret_cast<const char*>(I->getData());
312
313         // Skip things that don't make sense to print
314         if (I->isSVR4SymbolTable() || I->isBSD4SymbolTable())
315           continue;
316
317         if (Verbose)
318           outs() << "Printing " << I->getPath().str() << "\n";
319
320         unsigned len = I->getSize();
321         outs().write(data, len);
322       } else {
323         countDown--;
324       }
325     }
326   }
327   return false;
328 }
329
330 // putMode - utility function for printing out the file mode when the 't'
331 // operation is in verbose mode.
332 void
333 printMode(unsigned mode) {
334   if (mode & 004)
335     outs() << "r";
336   else
337     outs() << "-";
338   if (mode & 002)
339     outs() << "w";
340   else
341     outs() << "-";
342   if (mode & 001)
343     outs() << "x";
344   else
345     outs() << "-";
346 }
347
348 // doDisplayTable - Implement the 't' operation. This function prints out just
349 // the file names of each of the members. However, if verbose mode is requested
350 // ('v' modifier) then the file type, permission mode, user, group, size, and
351 // modification time are also printed.
352 bool
353 doDisplayTable(std::string* ErrMsg) {
354   if (buildPaths(false, ErrMsg))
355     return true;
356   for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
357        I != E; ++I ) {
358     if (Paths.empty() ||
359         (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
360       if (Verbose) {
361         // FIXME: Output should be this format:
362         // Zrw-r--r--  500/ 500    525 Nov  8 17:42 2004 Makefile
363         outs() << " ";
364         unsigned mode = I->getMode();
365         printMode((mode >> 6) & 007);
366         printMode((mode >> 3) & 007);
367         printMode(mode & 007);
368         outs() << " " << format("%4u", I->getUser());
369         outs() << "/" << format("%4u", I->getGroup());
370         outs() << " " << format("%8u", I->getSize());
371         outs() << " " << format("%20s", I->getModTime().str().substr(4).c_str());
372         outs() << " " << I->getPath().str() << "\n";
373       } else {
374         outs() << I->getPath().str() << "\n";
375       }
376     }
377   }
378   return false;
379 }
380
381 // doExtract - Implement the 'x' operation. This function extracts files back to
382 // the file system.
383 bool
384 doExtract(std::string* ErrMsg) {
385   if (buildPaths(false, ErrMsg))
386     return true;
387   for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
388        I != E; ++I ) {
389     if (Paths.empty() ||
390         (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
391
392       // Open up a file stream for writing
393       int OpenFlags = O_TRUNC | O_WRONLY | O_CREAT;
394 #ifdef O_BINARY
395       OpenFlags |= O_BINARY;
396 #endif
397
398       // Retain the original mode.
399       sys::fs::perms Mode = sys::fs::perms(I->getMode());
400
401       int FD = open(I->getPath().str().c_str(), OpenFlags, Mode);
402       if (FD < 0)
403         return true;
404
405       {
406         raw_fd_ostream file(FD, false);
407
408         // Get the data and its length
409         const char* data = reinterpret_cast<const char*>(I->getData());
410         unsigned len = I->getSize();
411
412         // Write the data.
413         file.write(data, len);
414       }
415
416       // If we're supposed to retain the original modification times, etc. do so
417       // now.
418       if (OriginalDates) {
419         error_code EC =
420             sys::fs::setLastModificationAndAccessTime(FD, I->getModTime());
421         if (EC)
422           fail(EC.message());
423       }
424       if (close(FD))
425         return true;
426     }
427   }
428   return false;
429 }
430
431 // doDelete - Implement the delete operation. This function deletes zero or more
432 // members from the archive. Note that if the count is specified, there should
433 // be no more than one path in the Paths list or else this algorithm breaks.
434 // That check is enforced in parseCommandLine (above).
435 bool
436 doDelete(std::string* ErrMsg) {
437   if (buildPaths(false, ErrMsg))
438     return true;
439   if (Paths.empty())
440     return false;
441   unsigned countDown = Count;
442   for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
443        I != E; ) {
444     if (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end()) {
445       if (countDown == 1) {
446         Archive::iterator J = I;
447         ++I;
448         TheArchive->erase(J);
449       } else
450         countDown--;
451     } else {
452       ++I;
453     }
454   }
455
456   // We're done editting, reconstruct the archive.
457   if (TheArchive->writeToDisk(ErrMsg))
458     return true;
459   return false;
460 }
461
462 // doMore - Implement the move operation. This function re-arranges just the
463 // order of the archive members so that when the archive is written the move
464 // of the members is accomplished. Note the use of the RelPos variable to
465 // determine where the items should be moved to.
466 bool
467 doMove(std::string* ErrMsg) {
468   if (buildPaths(false, ErrMsg))
469     return true;
470
471   // By default and convention the place to move members to is the end of the
472   // archive.
473   Archive::iterator moveto_spot = TheArchive->end();
474
475   // However, if the relative positioning modifiers were used, we need to scan
476   // the archive to find the member in question. If we don't find it, its no
477   // crime, we just move to the end.
478   if (AddBefore || InsertBefore || AddAfter) {
479     for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
480          I != E; ++I ) {
481       if (RelPos == I->getPath().str()) {
482         if (AddAfter) {
483           moveto_spot = I;
484           moveto_spot++;
485         } else {
486           moveto_spot = I;
487         }
488         break;
489       }
490     }
491   }
492
493   // Keep a list of the paths remaining to be moved
494   std::set<std::string> remaining(Paths);
495
496   // Scan the archive again, this time looking for the members to move to the
497   // moveto_spot.
498   for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
499        I != E && !remaining.empty(); ++I ) {
500     std::set<std::string>::iterator found =
501       std::find(remaining.begin(),remaining.end(), I->getPath());
502     if (found != remaining.end()) {
503       if (I != moveto_spot)
504         TheArchive->splice(moveto_spot,*TheArchive,I);
505       remaining.erase(found);
506     }
507   }
508
509   // We're done editting, reconstruct the archive.
510   if (TheArchive->writeToDisk(ErrMsg))
511     return true;
512   return false;
513 }
514
515 // doQuickAppend - Implements the 'q' operation. This function just
516 // indiscriminantly adds the members to the archive and rebuilds it.
517 bool
518 doQuickAppend(std::string* ErrMsg) {
519   // Get the list of paths to append.
520   if (buildPaths(true, ErrMsg))
521     return true;
522   if (Paths.empty())
523     return false;
524
525   // Append them quickly.
526   for (std::set<std::string>::iterator PI = Paths.begin(), PE = Paths.end();
527        PI != PE; ++PI) {
528     if (TheArchive->addFileBefore(*PI, TheArchive->end(), ErrMsg))
529       return true;
530   }
531
532   // We're done editting, reconstruct the archive.
533   if (TheArchive->writeToDisk(ErrMsg))
534     return true;
535   return false;
536 }
537
538 // doReplaceOrInsert - Implements the 'r' operation. This function will replace
539 // any existing files or insert new ones into the archive.
540 bool
541 doReplaceOrInsert(std::string* ErrMsg) {
542
543   // Build the list of files to be added/replaced.
544   if (buildPaths(true, ErrMsg))
545     return true;
546   if (Paths.empty())
547     return false;
548
549   // Keep track of the paths that remain to be inserted.
550   std::set<std::string> remaining(Paths);
551
552   // Default the insertion spot to the end of the archive
553   Archive::iterator insert_spot = TheArchive->end();
554
555   // Iterate over the archive contents
556   for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
557        I != E && !remaining.empty(); ++I ) {
558
559     // Determine if this archive member matches one of the paths we're trying
560     // to replace.
561
562     std::set<std::string>::iterator found = remaining.end();
563     for (std::set<std::string>::iterator RI = remaining.begin(),
564          RE = remaining.end(); RI != RE; ++RI ) {
565       std::string compare(sys::path::filename(*RI));
566       if (compare == I->getPath().str()) {
567         found = RI;
568         break;
569       }
570     }
571
572     if (found != remaining.end()) {
573       sys::fs::file_status Status;
574       error_code EC = sys::fs::status(*found, Status);
575       if (EC)
576         return true;
577       if (!sys::fs::is_directory(Status)) {
578         if (OnlyUpdate) {
579           // Replace the item only if it is newer.
580           if (Status.getLastModificationTime() > I->getModTime())
581             if (I->replaceWith(*found, ErrMsg))
582               return true;
583         } else {
584           // Replace the item regardless of time stamp
585           if (I->replaceWith(*found, ErrMsg))
586             return true;
587         }
588       } else {
589         // We purposefully ignore directories.
590       }
591
592       // Remove it from our "to do" list
593       remaining.erase(found);
594     }
595
596     // Determine if this is the place where we should insert
597     if ((AddBefore || InsertBefore) && RelPos == I->getPath().str())
598       insert_spot = I;
599     else if (AddAfter && RelPos == I->getPath().str()) {
600       insert_spot = I;
601       insert_spot++;
602     }
603   }
604
605   // If we didn't replace all the members, some will remain and need to be
606   // inserted at the previously computed insert-spot.
607   if (!remaining.empty()) {
608     for (std::set<std::string>::iterator PI = remaining.begin(),
609          PE = remaining.end(); PI != PE; ++PI) {
610       if (TheArchive->addFileBefore(*PI, insert_spot, ErrMsg))
611         return true;
612     }
613   }
614
615   // We're done editting, reconstruct the archive.
616   if (TheArchive->writeToDisk(ErrMsg))
617     return true;
618   return false;
619 }
620
621 bool shouldCreateArchive(ArchiveOperation Op) {
622   switch (Op) {
623   case Print:
624   case Delete:
625   case Move:
626   case DisplayTable:
627   case Extract:
628     return false;
629
630   case QuickAppend:
631   case ReplaceOrInsert:
632     return true;
633   }
634
635   llvm_unreachable("Missing entry in covered switch.");
636 }
637
638 // main - main program for llvm-ar .. see comments in the code
639 int main(int argc, char **argv) {
640   program_name = argv[0];
641   // Print a stack trace if we signal out.
642   sys::PrintStackTraceOnErrorSignal();
643   PrettyStackTraceProgram X(argc, argv);
644   LLVMContext &Context = getGlobalContext();
645   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
646
647   // Have the command line options parsed and handle things
648   // like --help and --version.
649   cl::ParseCommandLineOptions(argc, argv,
650     "LLVM Archiver (llvm-ar)\n\n"
651     "  This program archives bitcode files into single libraries\n"
652   );
653
654   int exitCode = 0;
655
656   // Do our own parsing of the command line because the CommandLine utility
657   // can't handle the grouped positional parameters without a dash.
658   ArchiveOperation Operation = parseCommandLine();
659
660   // Create or open the archive object.
661   if (shouldCreateArchive(Operation) && !llvm::sys::fs::exists(ArchiveName)) {
662     // Produce a warning if we should and we're creating the archive
663     if (!Create)
664       errs() << argv[0] << ": creating " << ArchiveName << "\n";
665     TheArchive = Archive::CreateEmpty(ArchiveName, Context);
666     TheArchive->writeToDisk();
667   }
668
669   if (!TheArchive) {
670     std::string Error;
671     TheArchive = Archive::OpenAndLoad(ArchiveName, Context, &Error);
672     if (TheArchive == 0) {
673       errs() << argv[0] << ": error loading '" << ArchiveName << "': "
674              << Error << "!\n";
675       return 1;
676     }
677   }
678
679   // Make sure we're not fooling ourselves.
680   assert(TheArchive && "Unable to instantiate the archive");
681
682   // Perform the operation
683   std::string ErrMsg;
684   bool haveError = false;
685   switch (Operation) {
686     case Print:           haveError = doPrint(&ErrMsg); break;
687     case Delete:          haveError = doDelete(&ErrMsg); break;
688     case Move:            haveError = doMove(&ErrMsg); break;
689     case QuickAppend:     haveError = doQuickAppend(&ErrMsg); break;
690     case ReplaceOrInsert: haveError = doReplaceOrInsert(&ErrMsg); break;
691     case DisplayTable:    haveError = doDisplayTable(&ErrMsg); break;
692     case Extract:         haveError = doExtract(&ErrMsg); break;
693   }
694   if (haveError) {
695     errs() << argv[0] << ": " << ErrMsg << "\n";
696     return 1;
697   }
698
699   delete TheArchive;
700   TheArchive = 0;
701
702   // Return result code back to operating system.
703   return exitCode;
704 }