[llvm-commits] CVS: llvm/tools/llvm-ar/llvm-ar.cpp

Reid Spencer reid at x10sys.com
Tue Aug 22 17:39:56 PDT 2006



Changes in directory llvm/tools/llvm-ar:

llvm-ar.cpp updated: 1.34 -> 1.35
---
Log message:

For PR797: http://llvm.org/PR797 :
Remove exceptions from the Path::create*OnDisk methods. Update their users
to handle error messages via arguments and result codes.


---
Diffs of the changes:  (+12 -4)

 llvm-ar.cpp |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)


Index: llvm/tools/llvm-ar/llvm-ar.cpp
diff -u llvm/tools/llvm-ar/llvm-ar.cpp:1.34 llvm/tools/llvm-ar/llvm-ar.cpp:1.35
--- llvm/tools/llvm-ar/llvm-ar.cpp:1.34	Tue Aug  1 13:09:46 2006
+++ llvm/tools/llvm-ar/llvm-ar.cpp	Tue Aug 22 19:39:35 2006
@@ -425,8 +425,8 @@
 }
 
 // doExtract - Implement the 'x' operation. This function extracts files back to
-// the file system, making sure to uncompress any that were compressed.
-void doExtract() {
+// the file system, making sure to uncompress any that were compressed
+bool doExtract(std::string* ErrMsg) {
   buildPaths(false);
   unsigned countDown = Count;
   for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
@@ -438,7 +438,8 @@
       if (I->hasPath()) {
         sys::Path dirs(I->getPath());
         dirs.eraseComponent();
-        dirs.createDirectoryOnDisk(/*create_parents=*/true);
+        if (dirs.createDirectoryOnDisk(/*create_parents=*/true, ErrMsg)) 
+          return true;
       }
 
       // Open up a file stream for writing
@@ -464,6 +465,7 @@
         I->getPath().setStatusInfoOnDisk(I->getFileStatus());
     }
   }
+  return false;
 }
 
 // doDelete - Implement the delete operation. This function deletes zero or more
@@ -711,6 +713,7 @@
     std::auto_ptr<Archive> AutoArchive(TheArchive);
 
     // Perform the operation
+    std::string ErrMsg;
     switch (Operation) {
       case Print:           doPrint(); break;
       case Delete:          doDelete(); break;
@@ -718,7 +721,12 @@
       case QuickAppend:      /* FALL THROUGH */
       case ReplaceOrInsert: doReplaceOrInsert(); break;
       case DisplayTable:    doDisplayTable(); break;
-      case Extract:         doExtract(); break;
+      case Extract:         
+        if (doExtract(&ErrMsg)) {
+          std::cerr << argv[0] << ": " << ErrMsg << "\n";
+          return 1;
+        }
+        break;
       case NoOperation:
         std::cerr << argv[0] << ": No operation was selected.\n";
         break;






More information about the llvm-commits mailing list