[llvm] r184337 - Always set the mode.

Rafael Espindola rafael.espindola at gmail.com
Wed Jun 19 12:17:15 PDT 2013


Author: rafael
Date: Wed Jun 19 14:17:15 2013
New Revision: 184337

URL: http://llvm.org/viewvc/llvm-project?rev=184337&view=rev
Log:
Always set the mode.

This matches GNU ar behavior. Also remove the now unused getFileStatus method.
Not sure how to add a test, it would have to run ls -l or something like that.

Modified:
    llvm/trunk/tools/llvm-ar/Archive.h
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/tools/llvm-ar/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/Archive.h?rev=184337&r1=184336&r2=184337&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/Archive.h (original)
+++ llvm/trunk/tools/llvm-ar/Archive.h Wed Jun 19 14:17:15 2013
@@ -137,15 +137,6 @@ class ArchiveMember : public ilist_node<
     /// @brief Determine if the member has a long file name
     bool hasLongFilename() const { return flags&HasLongFilenameFlag; }
 
-    /// This method returns the status info (like Unix stat(2)) for the archive
-    /// member. The status info provides the file's size, permissions, and
-    /// modification time. The contents of the Path::StatusInfo structure, other
-    /// than the size and modification time, may not have utility on non-Unix
-    /// systems.
-    /// @returns the status info for the archive member
-    /// @brief Obtain the status info for the archive member
-    const sys::FileStatus &getFileStatus() const { return info; }
-
     /// This method causes the archive member to be replaced with the contents
     /// of the file specified by \p File. The contents of \p this will be
     /// updated to reflect the new data from \p File. The \p File must exist and

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=184337&r1=184336&r2=184337&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Wed Jun 19 14:17:15 2013
@@ -440,12 +440,18 @@ doExtract(std::string* ErrMsg) {
       file.write(data,len);
       file.close();
 
+      sys::PathWithStatus PWS(I->getPath());
+      sys::FileStatus Status = *PWS.getFileStatus();
+
+      // Retain the original mode.
+      Status.mode = I->getMode();
+
       // If we're supposed to retain the original modification times, etc. do so
       // now.
-      if (OriginalDates) {
-        sys::PathWithStatus PWS(I->getPath());
-        PWS.setStatusInfoOnDisk(I->getFileStatus());
-      }
+      if (OriginalDates)
+        Status.modTime = I->getModTime();
+
+      PWS.setStatusInfoOnDisk(Status);
     }
   }
   return false;





More information about the llvm-commits mailing list