Reduce sys::Path usage in llvm-ar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184315 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2013-06-19 15:45:37 +00:00
parent 7c8397081c
commit 4d07abbb01
5 changed files with 39 additions and 35 deletions

View File

@@ -33,7 +33,7 @@ ArchiveMember::getMemberSize() const {
// If it has a long filename, include the name length
if (hasLongFilename())
result += path.str().length() + 1;
result += path.length() + 1;
// If its now odd lengthed, include the padding byte
if (result % 2 != 0 )
@@ -76,35 +76,35 @@ bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
}
data = 0;
path = newFile;
path = newFile.str();
// SVR4 symbol tables have an empty name
if (path.str() == ARFILE_SVR4_SYMTAB_NAME)
if (path == ARFILE_SVR4_SYMTAB_NAME)
flags |= SVR4SymbolTableFlag;
else
flags &= ~SVR4SymbolTableFlag;
// BSD4.4 symbol tables have a special name
if (path.str() == ARFILE_BSD4_SYMTAB_NAME)
if (path == ARFILE_BSD4_SYMTAB_NAME)
flags |= BSD4SymbolTableFlag;
else
flags &= ~BSD4SymbolTableFlag;
// String table name
if (path.str() == ARFILE_STRTAB_NAME)
if (path == ARFILE_STRTAB_NAME)
flags |= StringTableFlag;
else
flags &= ~StringTableFlag;
// If it has a slash then it has a path
bool hasSlash = path.str().find('/') != std::string::npos;
bool hasSlash = path.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.str().length() > 15)
if (hasSlash || path.length() > 15)
flags |= HasLongFilenameFlag;
else
flags &= ~HasLongFilenameFlag;
@@ -113,9 +113,10 @@ bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
const char* signature = (const char*) data;
SmallString<4> magic;
if (!signature) {
sys::fs::get_magic(path.str(), magic.capacity(), magic);
sys::fs::get_magic(path, magic.capacity(), magic);
signature = magic.c_str();
const sys::FileStatus *FSinfo = path.getFileStatus(false, ErrMsg);
sys::PathWithStatus PWS(path);
const sys::FileStatus *FSinfo = PWS.getFileStatus(false, ErrMsg);
if (FSinfo)
info = *FSinfo;
else