#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/System/Signals.h"
-#include <iostream>
+#include "llvm/Support/Signals.h"
#include <algorithm>
-#include <iomanip>
#include <memory>
+#include <fstream>
using namespace llvm;
// Option for compatibility with AIX, not used but must allow it to be present.
// printSymbolTable - print out the archive's symbol table.
void printSymbolTable() {
- std::cout << "\nArchive Symbol Table:\n";
+ outs() << "\nArchive Symbol Table:\n";
const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
I != E; ++I ) {
unsigned offset = TheArchive->getFirstFileOffset() + I->second;
- std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
+ outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
}
}
continue;
if (Verbose)
- std::cout << "Printing " << I->getPath().toString() << "\n";
+ outs() << "Printing " << I->getPath().str() << "\n";
unsigned len = I->getSize();
- std::cout.write(data, len);
+ outs().write(data, len);
} else {
countDown--;
}
void
printMode(unsigned mode) {
if (mode & 004)
- std::cout << "r";
+ outs() << "r";
else
- std::cout << "-";
+ outs() << "-";
if (mode & 002)
- std::cout << "w";
+ outs() << "w";
else
- std::cout << "-";
+ outs() << "-";
if (mode & 001)
- std::cout << "x";
+ outs() << "x";
else
- std::cout << "-";
+ outs() << "-";
}
// doDisplayTable - Implement the 't' operation. This function prints out just
// FIXME: Output should be this format:
// Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile
if (I->isBitcode())
- std::cout << "b";
+ outs() << "b";
else if (I->isCompressed())
- std::cout << "Z";
+ outs() << "Z";
else
- std::cout << " ";
+ outs() << " ";
unsigned mode = I->getMode();
printMode((mode >> 6) & 007);
printMode((mode >> 3) & 007);
printMode(mode & 007);
- std::cout << " " << std::setw(4) << I->getUser();
- std::cout << "/" << std::setw(4) << I->getGroup();
- std::cout << " " << std::setw(8) << I->getSize();
- std::cout << " " << std::setw(20) <<
- I->getModTime().toString().substr(4);
- std::cout << " " << I->getPath().toString() << "\n";
+ outs() << " " << format("%4u", I->getUser());
+ outs() << "/" << format("%4u", I->getGroup());
+ outs() << " " << format("%8u", I->getSize());
+ outs() << " " << format("%20s", I->getModTime().str().substr(4).c_str());
+ outs() << " " << I->getPath().str() << "\n";
} else {
- std::cout << I->getPath().toString() << "\n";
+ outs() << I->getPath().str() << "\n";
}
}
}
if (AddBefore || InsertBefore || AddAfter) {
for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
I != E; ++I ) {
- if (RelPos == I->getPath().toString()) {
+ if (RelPos == I->getPath().str()) {
if (AddAfter) {
moveto_spot = I;
moveto_spot++;
std::set<sys::Path>::iterator found = remaining.end();
for (std::set<sys::Path>::iterator RI = remaining.begin(),
RE = remaining.end(); RI != RE; ++RI ) {
- std::string compare(RI->toString());
+ std::string compare(RI->str());
if (TruncateNames && compare.length() > 15) {
const char* nm = compare.c_str();
unsigned len = compare.length();
len = 15;
compare.assign(nm,len);
}
- if (compare == I->getPath().toString()) {
+ if (compare == I->getPath().str()) {
found = RI;
break;
}
}
// Determine if this is the place where we should insert
- if ((AddBefore || InsertBefore) && (RelPos == I->getPath().toString()))
+ if ((AddBefore || InsertBefore) && RelPos == I->getPath().str())
insert_spot = I;
- else if (AddAfter && (RelPos == I->getPath().toString())) {
+ else if (AddAfter && RelPos == I->getPath().str()) {
insert_spot = I;
insert_spot++;
}
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
- LLVMContext Context;
+ LLVMContext &Context = getGlobalContext();
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
// Have the command line options parsed and handle things
if (!ArchivePath.exists()) {
// Produce a warning if we should and we're creating the archive
if (!Create)
- errs() << argv[0] << ": creating " << ArchivePath.toString() << "\n";
+ errs() << argv[0] << ": creating " << ArchivePath.str() << "\n";
TheArchive = Archive::CreateEmpty(ArchivePath, Context);
TheArchive->writeToDisk();
} else {
std::string Error;
TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error);
if (TheArchive == 0) {
- errs() << argv[0] << ": error loading '" << ArchivePath << "': "
+ errs() << argv[0] << ": error loading '" << ArchivePath.str() << "': "
<< Error << "!\n";
return 1;
}