Remove this file; the code that it went with is no longer
[oota-llvm.git] / lib / Archive / ArchiveWriter.cpp
index afe9819deeace613d6555ce60865729e829a4e4d..2269464c6c5351915e8e90f192612431d1f7ad07 100644 (file)
@@ -25,7 +25,7 @@ using namespace llvm;
 
 // Write an integer using variable bit rate encoding. This saves a few bytes
 // per entry in the symbol table.
-inline void writeInteger(unsigned num, std::ofstream& ARFile) {
+static inline void writeInteger(unsigned num, std::ofstream& ARFile) {
   while (1) {
     if (num < 0x80) { // done?
       ARFile << (unsigned char)num;
@@ -41,7 +41,7 @@ inline void writeInteger(unsigned num, std::ofstream& ARFile) {
 
 // Compute how many bytes are taken by a given VBR encoded value. This is needed
 // to pre-compute the size of the symbol table.
-inline unsigned numVbrBytes(unsigned num) {
+static inline unsigned numVbrBytes(unsigned num) {
 
   // Note that the following nested ifs are somewhat equivalent to a binary
   // search. We split it in half by comparing against 2^14 first. This allows
@@ -212,8 +212,7 @@ Archive::writeMember(
   const char *data = (const char*)member.getData();
   MemoryBuffer *mFile = 0;
   if (!data) {
-    mFile = MemoryBuffer::getFile(member.getPath().c_str(),
-                                  member.getPath().size(), ErrMsg);
+    mFile = MemoryBuffer::getFile(member.getPath().c_str(), ErrMsg);
     if (mFile == 0)
       return true;
     data = mFile->getBufferStart();
@@ -407,8 +406,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
 
     // Map in the archive we just wrote.
     {
-    OwningPtr<MemoryBuffer> arch(MemoryBuffer::getFile(TmpArchive.c_str(),
-                                                       TmpArchive.size()));
+    OwningPtr<MemoryBuffer> arch(MemoryBuffer::getFile(TmpArchive.c_str()));
     if (arch == 0) return true;
     const char* base = arch->getBufferStart();
 
@@ -469,5 +467,12 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
   if (TmpArchive.renamePathOnDisk(archPath, ErrMsg))
     return true;
 
+  // Set correct read and write permissions after temporary file is moved
+  // to final destination path.
+  if (archPath.makeReadableOnDisk(ErrMsg))
+    return true;
+  if (archPath.makeWriteableOnDisk(ErrMsg))
+    return true;
+
   return false;
 }