forked from OSchip/llvm-project
Remove last use of PathV1.h from Archive.h
Store the individual fields we need instead of a sys::FileStatus. llvm-svn: 184353
This commit is contained in:
parent
7a639ea2a4
commit
fca038907d
|
@ -29,7 +29,7 @@ using namespace llvm;
|
||||||
unsigned
|
unsigned
|
||||||
ArchiveMember::getMemberSize() const {
|
ArchiveMember::getMemberSize() const {
|
||||||
// Basically its the file size plus the header size
|
// Basically its the file size plus the header size
|
||||||
unsigned result = info.fileSize + sizeof(ArchiveMemberHeader);
|
unsigned result = Size + sizeof(ArchiveMemberHeader);
|
||||||
|
|
||||||
// If it has a long filename, include the name length
|
// If it has a long filename, include the name length
|
||||||
if (hasLongFilename())
|
if (hasLongFilename())
|
||||||
|
@ -47,11 +47,11 @@ ArchiveMember::getMemberSize() const {
|
||||||
ArchiveMember::ArchiveMember()
|
ArchiveMember::ArchiveMember()
|
||||||
: parent(0), path("--invalid--"), flags(0), data(0)
|
: parent(0), path("--invalid--"), flags(0), data(0)
|
||||||
{
|
{
|
||||||
info.user = sys::Process::GetCurrentUserId();
|
User = sys::Process::GetCurrentUserId();
|
||||||
info.group = sys::Process::GetCurrentGroupId();
|
Group = sys::Process::GetCurrentGroupId();
|
||||||
info.mode = 0777;
|
Mode = 0777;
|
||||||
info.fileSize = 0;
|
Size = 0;
|
||||||
info.modTime = sys::TimeValue::now();
|
ModTime = sys::TimeValue::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the constructor that the Archive class uses when it is building or
|
// This is the constructor that the Archive class uses when it is building or
|
||||||
|
@ -117,10 +117,13 @@ bool ArchiveMember::replaceWith(StringRef newFile, std::string* ErrMsg) {
|
||||||
signature = magic.c_str();
|
signature = magic.c_str();
|
||||||
sys::PathWithStatus PWS(path);
|
sys::PathWithStatus PWS(path);
|
||||||
const sys::FileStatus *FSinfo = PWS.getFileStatus(false, ErrMsg);
|
const sys::FileStatus *FSinfo = PWS.getFileStatus(false, ErrMsg);
|
||||||
if (FSinfo)
|
if (!FSinfo)
|
||||||
info = *FSinfo;
|
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
|
User = FSinfo->getUser();
|
||||||
|
Group = FSinfo->getGroup();
|
||||||
|
Mode = FSinfo->getMode();
|
||||||
|
ModTime = FSinfo->getTimestamp();
|
||||||
|
Size = FSinfo->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine what kind of file it is.
|
// Determine what kind of file it is.
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "llvm/ADT/ilist.h"
|
#include "llvm/ADT/ilist.h"
|
||||||
#include "llvm/ADT/ilist_node.h"
|
#include "llvm/ADT/ilist_node.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/PathV1.h"
|
#include "llvm/Support/TimeValue.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
@ -72,28 +72,28 @@ class ArchiveMember : public ilist_node<ArchiveMember> {
|
||||||
/// have any applicability on non-Unix systems but is a required component
|
/// have any applicability on non-Unix systems but is a required component
|
||||||
/// of the "ar" file format.
|
/// of the "ar" file format.
|
||||||
/// @brief Get the user associated with this archive member.
|
/// @brief Get the user associated with this archive member.
|
||||||
unsigned getUser() const { return info.getUser(); }
|
unsigned getUser() const { return User; }
|
||||||
|
|
||||||
/// The "group" is the owning group of the file per Unix security. This
|
/// The "group" is the owning group of the file per Unix security. This
|
||||||
/// may not have any applicability on non-Unix systems but is a required
|
/// may not have any applicability on non-Unix systems but is a required
|
||||||
/// component of the "ar" file format.
|
/// component of the "ar" file format.
|
||||||
/// @brief Get the group associated with this archive member.
|
/// @brief Get the group associated with this archive member.
|
||||||
unsigned getGroup() const { return info.getGroup(); }
|
unsigned getGroup() const { return Group; }
|
||||||
|
|
||||||
/// The "mode" specifies the access permissions for the file per Unix
|
/// The "mode" specifies the access permissions for the file per Unix
|
||||||
/// security. This may not have any applicability on non-Unix systems but is
|
/// security. This may not have any applicability on non-Unix systems but is
|
||||||
/// a required component of the "ar" file format.
|
/// a required component of the "ar" file format.
|
||||||
/// @brief Get the permission mode associated with this archive member.
|
/// @brief Get the permission mode associated with this archive member.
|
||||||
unsigned getMode() const { return info.getMode(); }
|
unsigned getMode() const { return Mode; }
|
||||||
|
|
||||||
/// This method returns the time at which the archive member was last
|
/// This method returns the time at which the archive member was last
|
||||||
/// modified when it was not in the archive.
|
/// modified when it was not in the archive.
|
||||||
/// @brief Get the time of last modification of the archive member.
|
/// @brief Get the time of last modification of the archive member.
|
||||||
sys::TimeValue getModTime() const { return info.getTimestamp(); }
|
sys::TimeValue getModTime() const { return ModTime; }
|
||||||
|
|
||||||
/// @returns the size of the archive member in bytes.
|
/// @returns the size of the archive member in bytes.
|
||||||
/// @brief Get the size of the archive member.
|
/// @brief Get the size of the archive member.
|
||||||
uint64_t getSize() const { return info.getSize(); }
|
uint64_t getSize() const { return Size; }
|
||||||
|
|
||||||
/// This method returns the total size of the archive member as it
|
/// This method returns the total size of the archive member as it
|
||||||
/// appears on disk. This includes the file content, the header, the
|
/// appears on disk. This includes the file content, the header, the
|
||||||
|
@ -149,11 +149,15 @@ class ArchiveMember : public ilist_node<ArchiveMember> {
|
||||||
/// @name Data
|
/// @name Data
|
||||||
/// @{
|
/// @{
|
||||||
private:
|
private:
|
||||||
Archive* parent; ///< Pointer to parent archive
|
Archive *parent; ///< Pointer to parent archive
|
||||||
std::string path; ///< Path of file containing the member
|
std::string path; ///< Path of file containing the member
|
||||||
sys::FileStatus info; ///< Status info (size,mode,date)
|
uint32_t User;
|
||||||
unsigned flags; ///< Flags about the archive member
|
uint32_t Group;
|
||||||
const char* data; ///< Data for the member
|
uint32_t Mode;
|
||||||
|
sys::TimeValue ModTime;
|
||||||
|
uint64_t Size;
|
||||||
|
unsigned flags; ///< Flags about the archive member
|
||||||
|
const char *data; ///< Data for the member
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Constructors
|
/// @name Constructors
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "Archive.h"
|
#include "Archive.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/Support/PathV1.h"
|
||||||
#include "llvm/Support/TimeValue.h"
|
#include "llvm/Support/TimeValue.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
|
@ -175,13 +175,13 @@ Archive::parseMemberHeader(const char*& At, const char* End, std::string* error)
|
||||||
// Fill in fields of the ArchiveMember
|
// Fill in fields of the ArchiveMember
|
||||||
member->parent = this;
|
member->parent = this;
|
||||||
member->path = pathname;
|
member->path = pathname;
|
||||||
member->info.fileSize = MemberSize;
|
member->Size = MemberSize;
|
||||||
member->info.modTime.fromEpochTime(atoi(Hdr->date));
|
member->ModTime.fromEpochTime(atoi(Hdr->date));
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
sscanf(Hdr->mode, "%o", &mode);
|
sscanf(Hdr->mode, "%o", &mode);
|
||||||
member->info.mode = mode;
|
member->Mode = mode;
|
||||||
member->info.user = atoi(Hdr->uid);
|
member->User = atoi(Hdr->uid);
|
||||||
member->info.group = atoi(Hdr->gid);
|
member->Group = atoi(Hdr->gid);
|
||||||
member->flags = flags;
|
member->flags = flags;
|
||||||
member->data = At;
|
member->data = At;
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,11 @@ bool Archive::addFileBefore(StringRef filePath, iterator where,
|
||||||
delete mbr;
|
delete mbr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mbr->info = *FSInfo;
|
mbr->User = FSInfo->getUser();
|
||||||
|
mbr->Group = FSInfo->getGroup();
|
||||||
|
mbr->Mode = FSInfo->getMode();
|
||||||
|
mbr->ModTime = FSInfo->getTimestamp();
|
||||||
|
mbr->Size = FSInfo->getSize();
|
||||||
|
|
||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
bool hasSlash = filePath.str().find('/') != std::string::npos;
|
bool hasSlash = filePath.str().find('/') != std::string::npos;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
|
#include "llvm/Support/PathV1.h"
|
||||||
#include "llvm/Support/PrettyStackTrace.h"
|
#include "llvm/Support/PrettyStackTrace.h"
|
||||||
#include "llvm/Support/Signals.h"
|
#include "llvm/Support/Signals.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
Loading…
Reference in New Issue