Path::get -> Path::toString

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18785 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2004-12-11 00:14:15 +00:00
parent 357cf5439a
commit 1fce09125c
21 changed files with 141 additions and 123 deletions

View File

@ -322,7 +322,7 @@ namespace sys {
/// by other software.
/// @returns std::string containing the path name.
/// @brief Returns the path as a std::string.
std::string get() const { return path; }
std::string toString() const { return path; }
/// This function returns the last component of the path name. If the
/// isDirectory() function would return true then this returns the name
@ -466,7 +466,7 @@ namespace sys {
/// @brief Create the directory this Path refers to.
bool createDirectory( bool create_parents = false );
/// This method attempts to create a file in the file system with the same
/// This method attempts to create a file in the file system with the same
/// name as the Path object. The intermediate directories must all exist
/// at the time this method is called. Use createDirectories to
/// accomplish that. The created file will be empty upon return from this
@ -500,7 +500,7 @@ namespace sys {
/// @brief Removes the file or directory from the filesystem.
bool destroyDirectory( bool destroy_contents = false );
/// This method attempts to destroy the file named by the last item in the
/// This method attempts to destroy the file named by the last item in the
/// Path name.
/// @returns false if the Path does not refer to a file, true otherwise.
/// @throws std::string if there is an error.

View File

@ -26,7 +26,7 @@ ArchiveMember::getMemberSize() const {
// If it has a long filename, include the name length
if (hasLongFilename())
result += path.get().length() + 1;
result += path.toString().length() + 1;
// If its now odd lengthed, include the padding byte
if (result % 2 != 0 )
@ -66,38 +66,38 @@ void ArchiveMember::replaceWith(const sys::Path& newFile) {
path = newFile;
// SVR4 symbol tables have an empty name
if (path.get() == ARFILE_SVR4_SYMTAB_NAME)
if (path.toString() == ARFILE_SVR4_SYMTAB_NAME)
flags |= SVR4SymbolTableFlag;
else
flags &= ~SVR4SymbolTableFlag;
// BSD4.4 symbol tables have a special name
if (path.get() == ARFILE_BSD4_SYMTAB_NAME)
if (path.toString() == ARFILE_BSD4_SYMTAB_NAME)
flags |= BSD4SymbolTableFlag;
else
flags &= ~BSD4SymbolTableFlag;
// LLVM symbol tables have a very specific name
if (path.get() == ARFILE_LLVM_SYMTAB_NAME)
if (path.toString() == ARFILE_LLVM_SYMTAB_NAME)
flags |= LLVMSymbolTableFlag;
else
flags &= ~LLVMSymbolTableFlag;
// String table name
if (path.get() == ARFILE_STRTAB_NAME)
if (path.toString() == ARFILE_STRTAB_NAME)
flags |= StringTableFlag;
else
flags &= ~StringTableFlag;
// If it has a slash then it has a path
bool hasSlash = path.get().find('/') != std::string::npos;
bool hasSlash = path.toString().find('/') != std::string::npos;
if (hasSlash)
flags |= HasPathFlag;
else
flags &= ~HasPathFlag;
// If it has a slash or its over 15 chars then its a long filename format
if (hasSlash || path.get().length() > 15)
if (hasSlash || path.toString().length() > 15)
flags |= HasLongFilenameFlag;
else
flags &= ~HasLongFilenameFlag;

View File

@ -295,8 +295,8 @@ Archive::getAllModules(std::vector<Module*>& Modules, std::string* ErrMessage) {
for (iterator I=begin(), E=end(); I != E; ++I) {
if (I->isBytecode() || I->isCompressedBytecode()) {
std::string FullMemberName = archPath.get() +
"(" + I->getPath().get() + ")";
std::string FullMemberName = archPath.toString() +
"(" + I->getPath().toString() + ")";
Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
I->getSize(), FullMemberName, ErrMessage);
if (!M)
@ -407,8 +407,8 @@ Archive::findModuleDefiningSymbol(const std::string& symbol) {
ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size());
// Now, load the bytecode module to get the ModuleProvider
std::string FullMemberName = archPath.get() + "(" +
mbr->getPath().get() + ")";
std::string FullMemberName = archPath.toString() + "(" +
mbr->getPath().toString() + ")";
ModuleProvider* mp = getBytecodeBufferModuleProvider(
(const unsigned char*) mbr->getData(), mbr->getSize(),
FullMemberName, 0);
@ -446,8 +446,8 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
// Get the symbols
std::vector<std::string> symbols;
std::string FullMemberName = archPath.get() + "(" +
mbr->getPath().get() + ")";
std::string FullMemberName = archPath.toString() + "(" +
mbr->getPath().toString() + ")";
ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
mbr->getSize(), FullMemberName, symbols);
@ -462,7 +462,7 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
modules.insert(std::make_pair(offset, std::make_pair(MP, mbr)));
} else {
throw std::string("Can't parse bytecode member: ") +
mbr->getPath().get();
mbr->getPath().toString();
}
}

View File

@ -94,7 +94,7 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
memcpy(hdr.date,buffer,12);
// Get rid of trailing blanks in the name
std::string mbrPath = mbr.getPath().get();
std::string mbrPath = mbr.getPath().toString();
size_t mbrLen = mbrPath.length();
while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') {
mbrPath.erase(mbrLen-1,1);
@ -162,10 +162,10 @@ Archive::addFileBefore(const sys::Path& filePath, iterator where) {
mbr->path.getStatusInfo(mbr->info);
unsigned flags = 0;
bool hasSlash = filePath.get().find('/') != std::string::npos;
bool hasSlash = filePath.toString().find('/') != std::string::npos;
if (hasSlash)
flags |= ArchiveMember::HasPathFlag;
if (hasSlash || filePath.get().length() > 15)
if (hasSlash || filePath.toString().length() > 15)
flags |= ArchiveMember::HasLongFilenameFlag;
std::string magic;
mbr->path.getMagicNumber(magic,4);
@ -212,7 +212,8 @@ Archive::writeMember(
if (CreateSymbolTable &&
(member.isBytecode() || member.isCompressedBytecode())) {
std::vector<std::string> symbols;
std::string FullMemberName = archPath.get() + "(" + member.getPath().get()
std::string FullMemberName = archPath.toString() + "(" +
member.getPath().toString()
+ ")";
ModuleProvider* MP = GetBytecodeSymbols(
(const unsigned char*)data,fSize,FullMemberName, symbols);
@ -235,7 +236,7 @@ Archive::writeMember(
delete MP;
} else {
throw std::string("Can't parse bytecode member: ") +
member.getPath().get();
member.getPath().toString();
}
}
@ -281,7 +282,8 @@ Archive::writeMember(
// Write the long filename if its long
if (writeLongName) {
ARFile.write(member.getPath().get().data(),member.getPath().get().length());
ARFile.write(member.getPath().toString().data(),
member.getPath().toString().length());
}
// Make sure we write the compressed bytecode magic number if we should.
@ -378,7 +380,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
// Check for errors opening or creating archive file.
if ( !ArchiveFile.is_open() || ArchiveFile.bad() ) {
throw std::string("Error opening archive file: ") + archPath.get();
throw std::string("Error opening archive file: ") + archPath.toString();
}
// If we're creating a symbol table, reset it now
@ -414,7 +416,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
// Open the final file to write and check it.
std::ofstream FinalFile(archPath.c_str());
if ( !FinalFile.is_open() || FinalFile.bad() ) {
throw std::string("Error opening archive file: ") + archPath.get();
throw std::string("Error opening archive file: ") + archPath.toString();
}
// Write the file magic number

View File

@ -26,7 +26,7 @@ ArchiveMember::getMemberSize() const {
// If it has a long filename, include the name length
if (hasLongFilename())
result += path.get().length() + 1;
result += path.toString().length() + 1;
// If its now odd lengthed, include the padding byte
if (result % 2 != 0 )
@ -66,38 +66,38 @@ void ArchiveMember::replaceWith(const sys::Path& newFile) {
path = newFile;
// SVR4 symbol tables have an empty name
if (path.get() == ARFILE_SVR4_SYMTAB_NAME)
if (path.toString() == ARFILE_SVR4_SYMTAB_NAME)
flags |= SVR4SymbolTableFlag;
else
flags &= ~SVR4SymbolTableFlag;
// BSD4.4 symbol tables have a special name
if (path.get() == ARFILE_BSD4_SYMTAB_NAME)
if (path.toString() == ARFILE_BSD4_SYMTAB_NAME)
flags |= BSD4SymbolTableFlag;
else
flags &= ~BSD4SymbolTableFlag;
// LLVM symbol tables have a very specific name
if (path.get() == ARFILE_LLVM_SYMTAB_NAME)
if (path.toString() == ARFILE_LLVM_SYMTAB_NAME)
flags |= LLVMSymbolTableFlag;
else
flags &= ~LLVMSymbolTableFlag;
// String table name
if (path.get() == ARFILE_STRTAB_NAME)
if (path.toString() == ARFILE_STRTAB_NAME)
flags |= StringTableFlag;
else
flags &= ~StringTableFlag;
// If it has a slash then it has a path
bool hasSlash = path.get().find('/') != std::string::npos;
bool hasSlash = path.toString().find('/') != std::string::npos;
if (hasSlash)
flags |= HasPathFlag;
else
flags &= ~HasPathFlag;
// If it has a slash or its over 15 chars then its a long filename format
if (hasSlash || path.get().length() > 15)
if (hasSlash || path.toString().length() > 15)
flags |= HasLongFilenameFlag;
else
flags &= ~HasLongFilenameFlag;

View File

@ -295,8 +295,8 @@ Archive::getAllModules(std::vector<Module*>& Modules, std::string* ErrMessage) {
for (iterator I=begin(), E=end(); I != E; ++I) {
if (I->isBytecode() || I->isCompressedBytecode()) {
std::string FullMemberName = archPath.get() +
"(" + I->getPath().get() + ")";
std::string FullMemberName = archPath.toString() +
"(" + I->getPath().toString() + ")";
Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
I->getSize(), FullMemberName, ErrMessage);
if (!M)
@ -407,8 +407,8 @@ Archive::findModuleDefiningSymbol(const std::string& symbol) {
ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size());
// Now, load the bytecode module to get the ModuleProvider
std::string FullMemberName = archPath.get() + "(" +
mbr->getPath().get() + ")";
std::string FullMemberName = archPath.toString() + "(" +
mbr->getPath().toString() + ")";
ModuleProvider* mp = getBytecodeBufferModuleProvider(
(const unsigned char*) mbr->getData(), mbr->getSize(),
FullMemberName, 0);
@ -446,8 +446,8 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
// Get the symbols
std::vector<std::string> symbols;
std::string FullMemberName = archPath.get() + "(" +
mbr->getPath().get() + ")";
std::string FullMemberName = archPath.toString() + "(" +
mbr->getPath().toString() + ")";
ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
mbr->getSize(), FullMemberName, symbols);
@ -462,7 +462,7 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
modules.insert(std::make_pair(offset, std::make_pair(MP, mbr)));
} else {
throw std::string("Can't parse bytecode member: ") +
mbr->getPath().get();
mbr->getPath().toString();
}
}

View File

@ -94,7 +94,7 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
memcpy(hdr.date,buffer,12);
// Get rid of trailing blanks in the name
std::string mbrPath = mbr.getPath().get();
std::string mbrPath = mbr.getPath().toString();
size_t mbrLen = mbrPath.length();
while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') {
mbrPath.erase(mbrLen-1,1);
@ -162,10 +162,10 @@ Archive::addFileBefore(const sys::Path& filePath, iterator where) {
mbr->path.getStatusInfo(mbr->info);
unsigned flags = 0;
bool hasSlash = filePath.get().find('/') != std::string::npos;
bool hasSlash = filePath.toString().find('/') != std::string::npos;
if (hasSlash)
flags |= ArchiveMember::HasPathFlag;
if (hasSlash || filePath.get().length() > 15)
if (hasSlash || filePath.toString().length() > 15)
flags |= ArchiveMember::HasLongFilenameFlag;
std::string magic;
mbr->path.getMagicNumber(magic,4);
@ -212,7 +212,8 @@ Archive::writeMember(
if (CreateSymbolTable &&
(member.isBytecode() || member.isCompressedBytecode())) {
std::vector<std::string> symbols;
std::string FullMemberName = archPath.get() + "(" + member.getPath().get()
std::string FullMemberName = archPath.toString() + "(" +
member.getPath().toString()
+ ")";
ModuleProvider* MP = GetBytecodeSymbols(
(const unsigned char*)data,fSize,FullMemberName, symbols);
@ -235,7 +236,7 @@ Archive::writeMember(
delete MP;
} else {
throw std::string("Can't parse bytecode member: ") +
member.getPath().get();
member.getPath().toString();
}
}
@ -281,7 +282,8 @@ Archive::writeMember(
// Write the long filename if its long
if (writeLongName) {
ARFile.write(member.getPath().get().data(),member.getPath().get().length());
ARFile.write(member.getPath().toString().data(),
member.getPath().toString().length());
}
// Make sure we write the compressed bytecode magic number if we should.
@ -378,7 +380,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
// Check for errors opening or creating archive file.
if ( !ArchiveFile.is_open() || ArchiveFile.bad() ) {
throw std::string("Error opening archive file: ") + archPath.get();
throw std::string("Error opening archive file: ") + archPath.toString();
}
// If we're creating a symbol table, reset it now
@ -414,7 +416,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
// Open the final file to write and check it.
std::ofstream FinalFile(archPath.c_str());
if ( !FinalFile.is_open() || FinalFile.bad() ) {
throw std::string("Error opening archive file: ") + archPath.get();
throw std::string("Error opening archive file: ") + archPath.toString();
}
// Write the file magic number

View File

@ -374,7 +374,8 @@ void getSymbols(Module*M, std::vector<std::string>& symbols) {
bool llvm::GetBytecodeSymbols(const sys::Path& fName,
std::vector<std::string>& symbols) {
try {
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fName.get()));
std::auto_ptr<ModuleProvider> AMP(
getBytecodeModuleProvider(fName.toString()));
// Get the module from the provider
Module* M = AMP->materializeModule();

View File

@ -44,17 +44,17 @@ void MappedFile::initialize() {
if (info_->fd_ < 0) {
delete info_;
info_ = 0;
ThrowErrno(std::string("Can't open file: ") + path_.get());
ThrowErrno(std::string("Can't open file: ") + path_.toString());
}
struct stat sbuf;
if(::fstat(info_->fd_, &info_->sbuf_) < 0) {
::close(info_->fd_);
delete info_;
info_ = 0;
ThrowErrno(std::string("Can't stat file: ") + path_.get());
ThrowErrno(std::string("Can't stat file: ") + path_.toString());
}
} else {
throw std::string("Can't open file: ") + path_.get();
throw std::string("Can't open file: ") + path_.toString();
}
}
@ -103,7 +103,7 @@ void* MappedFile::map() {
base_ = ::mmap(0, map_size, prot, flags, info_->fd_, 0);
if (base_ == MAP_FAILED)
ThrowErrno(std::string("Can't map file:") + path_.get());
ThrowErrno(std::string("Can't map file:") + path_.toString());
}
return base_;
}

View File

@ -44,17 +44,17 @@ void MappedFile::initialize() {
if (info_->fd_ < 0) {
delete info_;
info_ = 0;
ThrowErrno(std::string("Can't open file: ") + path_.get());
ThrowErrno(std::string("Can't open file: ") + path_.toString());
}
struct stat sbuf;
if(::fstat(info_->fd_, &info_->sbuf_) < 0) {
::close(info_->fd_);
delete info_;
info_ = 0;
ThrowErrno(std::string("Can't stat file: ") + path_.get());
ThrowErrno(std::string("Can't stat file: ") + path_.toString());
}
} else {
throw std::string("Can't open file: ") + path_.get();
throw std::string("Can't open file: ") + path_.toString();
}
}
@ -103,7 +103,7 @@ void* MappedFile::map() {
base_ = ::mmap(0, map_size, prot, flags, info_->fd_, 0);
if (base_ == MAP_FAILED)
ThrowErrno(std::string("Can't map file:") + path_.get());
ThrowErrno(std::string("Can't map file:") + path_.toString());
}
return base_;
}

View File

@ -21,7 +21,6 @@
#include "Unix.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <fstream>
#include <utime.h>
#include <dirent.h>
@ -192,10 +191,13 @@ bool
Path::isBytecodeFile() const {
char buffer[ 4];
buffer[0] = 0;
std::ifstream f(path.c_str());
f.read(buffer, 4);
if (f.bad())
ThrowErrno("can't read file signature");
int fd = ::open(path.c_str(),O_RDONLY);
if (fd < 0)
return false;
ssize_t bytes_read = ::read(fd, buffer, 4);
::close(fd);
if (4 != bytes_read)
return false;
return (buffer[0] == 'l' && buffer[1] == 'l' && buffer[2] == 'v' &&
(buffer[3] == 'c' || buffer[3] == 'm'));
@ -522,7 +524,8 @@ bool
Path::renameFile(const Path& newName) {
if (!isFile()) return false;
if (0 != rename(path.c_str(), newName.c_str()))
ThrowErrno(std::string("can't rename ") + path + " as " + newName.get());
ThrowErrno(std::string("can't rename ") + path + " as " +
newName.toString());
return true;
}

View File

@ -21,7 +21,6 @@
#include "Unix.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <fstream>
#include <utime.h>
#include <dirent.h>
@ -192,10 +191,13 @@ bool
Path::isBytecodeFile() const {
char buffer[ 4];
buffer[0] = 0;
std::ifstream f(path.c_str());
f.read(buffer, 4);
if (f.bad())
ThrowErrno("can't read file signature");
int fd = ::open(path.c_str(),O_RDONLY);
if (fd < 0)
return false;
ssize_t bytes_read = ::read(fd, buffer, 4);
::close(fd);
if (4 != bytes_read)
return false;
return (buffer[0] == 'l' && buffer[1] == 'l' && buffer[2] == 'v' &&
(buffer[3] == 'c' || buffer[3] == 'm'));
@ -522,7 +524,8 @@ bool
Path::renameFile(const Path& newName) {
if (!isFile()) return false;
if (0 != rename(path.c_str(), newName.c_str()))
ThrowErrno(std::string("can't rename ") + path + " as " + newName.get());
ThrowErrno(std::string("can't rename ") + path + " as " +
newName.toString());
return true;
}

View File

@ -81,7 +81,7 @@ int
Program::ExecuteAndWait(const Path& path,
const std::vector<std::string>& args) {
if (!path.executable())
throw path.get() + " is not executable";
throw path.toString() + " is not executable";
#ifdef HAVE_SYS_WAIT_H
// Create local versions of the parameters that can be passed into execve()
@ -98,7 +98,8 @@ Program::ExecuteAndWait(const Path& path,
switch (fork()) {
// An error occured: Return to the caller.
case -1:
ThrowErrno(std::string("Couldn't execute program '") + path.get() + "'");
ThrowErrno(std::string("Couldn't execute program '") + path.toString() +
"'");
break;
// Child process: Execute the program.
@ -116,13 +117,15 @@ Program::ExecuteAndWait(const Path& path,
// Parent process: Wait for the child process to terminate.
int status;
if ((::wait (&status)) == -1)
ThrowErrno(std::string("Failed waiting for program '") + path.get() + "'");
ThrowErrno(std::string("Failed waiting for program '") + path.toString()
+ "'");
// If the program exited normally with a zero exit status, return success!
if (WIFEXITED (status))
return WEXITSTATUS(status);
else if (WIFSIGNALED(status))
throw std::string("Program '") + path.get() + "' received terminating signal.";
throw std::string("Program '") + path.toString() +
"' received terminating signal.";
else
return 0;

View File

@ -81,7 +81,7 @@ int
Program::ExecuteAndWait(const Path& path,
const std::vector<std::string>& args) {
if (!path.executable())
throw path.get() + " is not executable";
throw path.toString() + " is not executable";
#ifdef HAVE_SYS_WAIT_H
// Create local versions of the parameters that can be passed into execve()
@ -98,7 +98,8 @@ Program::ExecuteAndWait(const Path& path,
switch (fork()) {
// An error occured: Return to the caller.
case -1:
ThrowErrno(std::string("Couldn't execute program '") + path.get() + "'");
ThrowErrno(std::string("Couldn't execute program '") + path.toString() +
"'");
break;
// Child process: Execute the program.
@ -116,13 +117,15 @@ Program::ExecuteAndWait(const Path& path,
// Parent process: Wait for the child process to terminate.
int status;
if ((::wait (&status)) == -1)
ThrowErrno(std::string("Failed waiting for program '") + path.get() + "'");
ThrowErrno(std::string("Failed waiting for program '") + path.toString()
+ "'");
// If the program exited normally with a zero exit status, return success!
if (WIFEXITED (status))
return WEXITSTATUS(status);
else if (WIFSIGNALED(status))
throw std::string("Program '") + path.get() + "' received terminating signal.";
throw std::string("Program '") + path.toString() +
"' received terminating signal.";
else
return 0;

View File

@ -138,7 +138,7 @@ void sys::RemoveFileOnSignal(const sys::Path &Filename) {
if (FilesToRemove == 0)
FilesToRemove = new std::vector<std::string>;
FilesToRemove->push_back(Filename.get());
FilesToRemove->push_back(Filename.toString());
std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);

View File

@ -138,7 +138,7 @@ void sys::RemoveFileOnSignal(const sys::Path &Filename) {
if (FilesToRemove == 0)
FilesToRemove = new std::vector<std::string>;
FilesToRemove->push_back(Filename.get());
FilesToRemove->push_back(Filename.toString());
std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);

View File

@ -345,7 +345,7 @@ void doPrint() {
continue;
if (Verbose)
std::cout << "Printing " << I->getPath().get() << "\n";
std::cout << "Printing " << I->getPath().toString() << "\n";
if (I->isCompressedBytecode())
Compressor::decompressToStream(data+4,I->getSize()-4,std::cout);
@ -409,9 +409,9 @@ void doDisplayTable() {
std::cout << " " << std::setw(8) << I->getSize();
std::cout << " " << std::setw(20) <<
I->getModTime().toString().substr(4);
std::cout << " " << I->getPath().get() << "\n";
std::cout << " " << I->getPath().toString() << "\n";
} else {
std::cout << I->getPath().get() << "\n";
std::cout << I->getPath().toString() << "\n";
}
}
}
@ -505,7 +505,7 @@ void doMove() {
if (AddBefore || InsertBefore || AddAfter) {
for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
I != E; ++I ) {
if (RelPos == I->getPath().get()) {
if (RelPos == I->getPath().toString()) {
if (AddAfter) {
moveto_spot = I;
moveto_spot++;
@ -582,7 +582,7 @@ void doReplaceOrInsert() {
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->get());
std::string compare(RI->toString());
if (TruncateNames && compare.length() > 15) {
const char* nm = compare.c_str();
unsigned len = compare.length();
@ -595,7 +595,7 @@ void doReplaceOrInsert() {
len = 15;
compare.assign(nm,len);
}
if (compare == I->getPath().get()) {
if (compare == I->getPath().toString()) {
found = RI;
break;
}
@ -622,9 +622,9 @@ void doReplaceOrInsert() {
}
// Determine if this is the place where we should insert
if ((AddBefore || InsertBefore) && (RelPos == I->getPath().get()))
if ((AddBefore || InsertBefore) && (RelPos == I->getPath().toString()))
insert_spot = I;
else if (AddAfter && (RelPos == I->getPath().get())) {
else if (AddAfter && (RelPos == I->getPath().toString())) {
insert_spot = I;
insert_spot++;
}
@ -675,7 +675,7 @@ int main(int argc, char **argv) {
if (!ArchivePath.exists()) {
// Produce a warning if we should and we're creating the archive
if (!Create)
std::cerr << argv[0] << ": creating " << ArchivePath.get() << "\n";
std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
TheArchive = Archive::CreateEmpty(ArchivePath);
} else {
TheArchive = Archive::OpenAndLoad(ArchivePath);

View File

@ -58,7 +58,7 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
std::string ErrorMessage;
if (Filename.exists()) {
if (Verbose) std::cerr << "Loading '" << Filename.c_str() << "'\n";
Module* Result = ParseBytecodeFile(Filename.get(), &ErrorMessage);
Module* Result = ParseBytecodeFile(Filename.toString(), &ErrorMessage);
if (Result) return std::auto_ptr<Module>(Result); // Load successful!
if (Verbose) {

View File

@ -190,7 +190,7 @@ private:
if (TempDir.isDirectory() && TempDir.writable())
TempDir.destroyDirectory(/*remove_contents=*/true);
} else {
std::cout << "Temporary files are in " << TempDir.get() << "\n";
std::cout << "Temporary files are in " << TempDir.toString() << "\n";
}
}
@ -270,12 +270,12 @@ private:
break;
case 'i':
if (*PI == "%in%") {
action->args.push_back(input.get());
action->args.push_back(input.toString());
} else if (*PI == "%incls%") {
PathVector::iterator I = IncludePaths.begin();
PathVector::iterator E = IncludePaths.end();
while (I != E) {
action->args.push_back( std::string("-I") + I->get() );
action->args.push_back( std::string("-I") + I->toString() );
++I;
}
} else
@ -286,7 +286,7 @@ private:
PathVector::iterator I = LibraryPaths.begin();
PathVector::iterator E = LibraryPaths.end();
while (I != E) {
action->args.push_back( std::string("-L") + I->get() );
action->args.push_back( std::string("-L") + I->toString() );
++I;
}
} else
@ -294,7 +294,7 @@ private:
break;
case 'o':
if (*PI == "%out%") {
action->args.push_back(output.get());
action->args.push_back(output.toString());
} else if (*PI == "%opt%") {
if (!isSet(EMIT_RAW_FLAG)) {
if (cd->opts.size() > static_cast<unsigned>(optLevel) &&
@ -358,7 +358,7 @@ private:
if (PI->length()>1 && (*PI)[0] == '%' &&
(*PI)[PI->length()-1] == '%') {
throw std::string("Invalid substitution token: '") + *PI +
"' for command '" + pat->program.get() + "'";
"' for command '" + pat->program.toString() + "'";
} else if (!PI->empty()) {
// It's not a legal substitution, just pass it through
action->args.push_back(*PI);
@ -381,18 +381,19 @@ private:
WriteAction(action);
if (!isSet(DRY_RUN_FLAG)) {
sys::Path progpath = sys::Program::FindProgramByName(
action->program.get());
action->program.toString());
if (progpath.isEmpty())
throw std::string("Can't find program '"+action->program.get()+"'");
throw std::string("Can't find program '" +
action->program.toString()+"'");
else if (progpath.executable())
action->program = progpath;
else
throw std::string("Program '"+action->program.get()+
throw std::string("Program '"+action->program.toString()+
"' is not executable.");
// Invoke the program
if (isSet(TIME_ACTIONS_FLAG)) {
Timer timer(action->program.get());
Timer timer(action->program.toString());
timer.startTimer();
int resultCode =
sys::Program::ExecuteAndWait(action->program,action->args);
@ -418,7 +419,7 @@ private:
return fullpath;
for (PathVector::iterator PI = LibraryPaths.begin(),
PE = LibraryPaths.end(); PI != PE; ++PI) {
fullpath.setDirectory(PI->get());
fullpath.setDirectory(PI->toString());
fullpath.appendFile(link_item);
if (fullpath.readable())
return fullpath;
@ -462,13 +463,13 @@ private:
if (!link_item.readable()) {
// look for the library using the -L arguments specified
// on the command line.
fullpath = GetPathForLinkageItem(link_item.get());
fullpath = GetPathForLinkageItem(link_item.toString());
// If we didn't find the file in any of the library search paths
// we have to bail. No where else to look.
if (fullpath.isEmpty()) {
err =
std::string("Can't find linkage item '") + link_item.get() + "'";
std::string("Can't find linkage item '") + link_item.toString() + "'";
return false;
}
} else {
@ -482,7 +483,7 @@ private:
if (fullpath.isBytecodeFile()) {
// Process the dependent libraries recursively
Module::LibraryListType modlibs;
if (GetBytecodeDependentLibraries(fullpath.get(),modlibs)) {
if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs)) {
// Traverse the dependent libraries list
Module::lib_iterator LI = modlibs.begin();
Module::lib_iterator LE = modlibs.end();
@ -491,9 +492,9 @@ private:
if (err.empty()) {
err = std::string("Library '") + *LI +
"' is not valid for linking but is required by file '" +
fullpath.get() + "'";
fullpath.toString() + "'";
} else {
err += " which is required by file '" + fullpath.get() + "'";
err += " which is required by file '" + fullpath.toString() + "'";
}
return false;
}
@ -502,7 +503,7 @@ private:
} else if (err.empty()) {
err = std::string(
"The dependent libraries could not be extracted from '") +
fullpath.get();
fullpath.toString();
return false;
}
}
@ -529,11 +530,11 @@ public:
std::cerr << "OutputMachine = " << machine << "\n";
InputList::const_iterator I = InpList.begin();
while ( I != InpList.end() ) {
std::cerr << "Input: " << I->first.get() << "(" << I->second
std::cerr << "Input: " << I->first.toString() << "(" << I->second
<< ")\n";
++I;
}
std::cerr << "Output: " << Output.get() << "\n";
std::cerr << "Output: " << Output.toString() << "\n";
}
// If there's no input, we're done.
@ -577,7 +578,7 @@ public:
"Pre-compiled objects found but linking not requested");
}
if (ftype.empty())
LibFiles.push_back(I->first.get());
LibFiles.push_back(I->first.toString());
else
LinkageItems.insert(I->first);
continue; // short circuit remainder of loop
@ -659,10 +660,10 @@ public:
/// We need to translate it to bytecode
Action* action = new Action();
action->program.setFile("llvm-as");
action->args.push_back(InFile.get());
action->args.push_back(InFile.toString());
action->args.push_back("-o");
InFile.appendSuffix("bc");
action->args.push_back(InFile.get());
action->args.push_back(InFile.toString());
actions.push_back(action);
}
}
@ -701,11 +702,11 @@ public:
/// We need to translate it to bytecode with llvm-as
Action* action = new Action();
action->program.setFile("llvm-as");
action->args.push_back(InFile.get());
action->args.push_back(InFile.toString());
action->args.push_back("-f");
action->args.push_back("-o");
InFile.appendSuffix("bc");
action->args.push_back(InFile.get());
action->args.push_back(InFile.toString());
actions.push_back(action);
}
}
@ -730,27 +731,27 @@ public:
if (isSet(EMIT_NATIVE_FLAG)) {
// Use llc to get the native assembly file
action->program.setFile("llc");
action->args.push_back(InFile.get());
action->args.push_back(InFile.toString());
action->args.push_back("-f");
action->args.push_back("-o");
if (Output.isEmpty()) {
OutFile.appendSuffix("o");
action->args.push_back(OutFile.get());
action->args.push_back(OutFile.toString());
} else {
action->args.push_back(Output.get());
action->args.push_back(Output.toString());
}
actions.push_back(action);
} else {
// Just convert back to llvm assembly with llvm-dis
action->program.setFile("llvm-dis");
action->args.push_back(InFile.get());
action->args.push_back(InFile.toString());
action->args.push_back("-f");
action->args.push_back("-o");
if (Output.isEmpty()) {
OutFile.appendSuffix("ll");
action->args.push_back(OutFile.get());
action->args.push_back(OutFile.toString());
} else {
action->args.push_back(Output.get());
action->args.push_back(Output.toString());
}
}
@ -812,7 +813,7 @@ public:
// -l arguments specified.
for (PathVector::const_iterator I=LinkageItems.begin(),
E=LinkageItems.end(); I != E; ++I )
link->args.push_back(I->get());
link->args.push_back(I->toString());
// Add in all the libraries we found.
for (std::vector<std::string>::const_iterator I=LibFiles.begin(),
@ -822,7 +823,7 @@ public:
// Add in all the library paths to the command line
for (PathVector::const_iterator I=LibraryPaths.begin(),
E=LibraryPaths.end(); I != E; ++I)
link->args.push_back( std::string("-L") + I->get());
link->args.push_back( std::string("-L") + I->toString());
// Add in the additional linker arguments requested
for (StringVector::const_iterator I=AdditionalArgs[LINKING].begin(),
@ -847,7 +848,7 @@ public:
// Add in mandatory flags
link->args.push_back("-o");
link->args.push_back(Output.get());
link->args.push_back(Output.toString());
// Execute the link
if (!DoAction(link))

View File

@ -582,7 +582,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
throw std::string("Configuration file for '") + ftype +
"' is not available.";
}
FileInputProvider fip( confFile.get() );
FileInputProvider fip( confFile.toString() );
if (!fip.okay()) {
throw std::string("Configuration file for '") + ftype +
"' is not available.";

View File

@ -241,7 +241,7 @@ const std::string GetFileType(const std::string& fname, unsigned pos ) {
void handleTerminatingOptions(CompilerDriver* CD) {
if (!PrintFileName.empty()) {
sys::Path path = CD->GetPathForLinkageItem(PrintFileName,false);
std::string p = path.get();
std::string p = path.toString();
if (p.empty())
std::cout << "Can't locate '" << PrintFileName << "'.\n";
else