Remove the 'R' modifier.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 19 Jun 2013 14:58:16 +0000 (14:58 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 19 Jun 2013 14:58:16 +0000 (14:58 +0000)
It is not present in GNU or OS X versions and doesn't make a lot of sense
for llvm-ar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184306 91177308-0d34-0410-b5e6-96231b3b80d8

test/Archive/directory.ll [new file with mode: 0644]
tools/llvm-ar/llvm-ar.cpp

diff --git a/test/Archive/directory.ll b/test/Archive/directory.ll
new file mode 100644 (file)
index 0000000..f17ac5d
--- /dev/null
@@ -0,0 +1,2 @@
+;RUN: not llvm-ar r %T/test.a . 2>&1 | FileCheck %s
+;CHECK: . Is a directory
index 2a4a3deecddf90598da3313b0b91e1b308463180..792b46bded0e46cb63fa7b18654caad8f8001aec 100644 (file)
@@ -96,7 +96,6 @@ bool DontSkipBitcode = false;    ///< 'k' modifier
 bool UseCount = false;           ///< 'N' modifier
 bool OriginalDates = false;      ///< 'o' modifier
 bool FullPath = false;           ///< 'P' modifier
-bool RecurseDirectories = false; ///< 'R' modifier
 bool SymTable = true;            ///< 's' & 'S' modifiers
 bool OnlyUpdate = false;         ///< 'u' modifier
 bool Verbose = false;            ///< 'v' modifier
@@ -218,7 +217,6 @@ ArchiveOperation parseCommandLine() {
     case 'l': /* accepted but unused */ break;
     case 'o': OriginalDates = true; break;
     case 'P': FullPath = true; break;
-    case 'R': RecurseDirectories = true; break;
     case 's': SymTable = true; break;
     case 'S': SymTable = false; break;
     case 'u': OnlyUpdate = true; break;
@@ -268,8 +266,6 @@ ArchiveOperation parseCommandLine() {
       show_help("The 'a', 'b' and 'i' modifiers can only be specified with "
             "the 'm' or 'r' operations");
   }
-  if (RecurseDirectories && Operation != ReplaceOrInsert)
-    show_help("The 'R' modifiers is only applicabe to the 'r' operation");
   if (OriginalDates && Operation != Extract)
     show_help("The 'o' modifier is only applicable to the 'x' operation");
   if (TruncateNames && Operation!=QuickAppend && Operation!=ReplaceOrInsert)
@@ -284,39 +280,6 @@ ArchiveOperation parseCommandLine() {
   return Operation;
 }
 
-// recurseDirectories - Implements the "R" modifier. This function scans through
-// the Paths vector (built by buildPaths, below) and replaces any directories it
-// finds with all the files in that directory (recursively). It uses the
-// sys::Path::getDirectoryContent method to perform the actual directory scans.
-bool
-recurseDirectories(const sys::Path& path,
-                   std::set<sys::Path>& result, std::string* ErrMsg) {
-  result.clear();
-  if (RecurseDirectories) {
-    std::set<sys::Path> content;
-    if (path.getDirectoryContents(content, ErrMsg))
-      return true;
-
-    for (std::set<sys::Path>::iterator I = content.begin(), E = content.end();
-         I != E; ++I) {
-      // Make sure it exists and is a directory
-      sys::PathWithStatus PwS(*I);
-      const sys::FileStatus *Status = PwS.getFileStatus(false, ErrMsg);
-      if (!Status)
-        return true;
-      if (Status->isDir) {
-        std::set<sys::Path> moreResults;
-        if (recurseDirectories(*I, moreResults, ErrMsg))
-          return true;
-        result.insert(moreResults.begin(), moreResults.end());
-      } else {
-          result.insert(*I);
-      }
-    }
-  }
-  return false;
-}
-
 // buildPaths - Convert the strings in the Members vector to sys::Path objects
 // and make sure they are valid and exist exist. This check is only needed for
 // the operations that add/replace files to the archive ('q' and 'r')
@@ -334,14 +297,10 @@ bool buildPaths(bool checkExistence, std::string* ErrMsg) {
       const sys::FileStatus *si = PwS.getFileStatus(false, &Err);
       if (!si)
         fail(Err);
-      if (si->isDir) {
-        std::set<sys::Path> dirpaths;
-        if (recurseDirectories(aPath, dirpaths, ErrMsg))
-          return true;
-        Paths.insert(dirpaths.begin(),dirpaths.end());
-      } else {
-        Paths.insert(aPath);
-      }
+      if (si->isDir)
+        fail(aPath.str() + " Is a directory");
+
+      Paths.insert(aPath);
     } else {
       Paths.insert(aPath);
     }