Revert "[VFS] Cleanups to VFS interfaces."
This reverts commit r337834 due to test failures. llvm-svn: 337850
This commit is contained in:
@@ -73,14 +73,16 @@ Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
|
||||
: Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
|
||||
Type(Type), Perms(Perms) {}
|
||||
|
||||
Status::Status(const file_status &In, StringRef NewName)
|
||||
: Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
|
||||
In.getUser(), In.getGroup(), In.getSize(), In.type(),
|
||||
In.permissions()) {}
|
||||
Status Status::copyWithNewName(const Status &In, StringRef NewName) {
|
||||
return Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
|
||||
In.getUser(), In.getGroup(), In.getSize(), In.getType(),
|
||||
In.getPermissions());
|
||||
}
|
||||
|
||||
Status Status::copyWithNewName(StringRef NewName) {
|
||||
return Status(NewName, getUniqueID(), getLastModificationTime(), getUser(),
|
||||
getGroup(), getSize(), getType(), getPermissions());
|
||||
Status Status::copyWithNewName(const file_status &In, StringRef NewName) {
|
||||
return Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
|
||||
In.getUser(), In.getGroup(), In.getSize(), In.type(),
|
||||
In.permissions());
|
||||
}
|
||||
|
||||
bool Status::equivalent(const Status &Other) const {
|
||||
@@ -176,7 +178,6 @@ class RealFile : public File {
|
||||
Status S;
|
||||
std::string RealName;
|
||||
|
||||
// NewRealPathName is used only if non-empty.
|
||||
RealFile(int FD, StringRef NewName, StringRef NewRealPathName)
|
||||
: FD(FD), S(NewName, {}, {}, {}, {}, {},
|
||||
llvm::sys::fs::file_type::status_error, {}),
|
||||
@@ -188,7 +189,7 @@ public:
|
||||
~RealFile() override;
|
||||
|
||||
ErrorOr<Status> status() override;
|
||||
Optional<std::string> getRealPath() override;
|
||||
ErrorOr<std::string> getName() override;
|
||||
ErrorOr<std::unique_ptr<MemoryBuffer>> getBuffer(const Twine &Name,
|
||||
int64_t FileSize,
|
||||
bool RequiresNullTerminator,
|
||||
@@ -206,15 +207,13 @@ ErrorOr<Status> RealFile::status() {
|
||||
file_status RealStatus;
|
||||
if (std::error_code EC = sys::fs::status(FD, RealStatus))
|
||||
return EC;
|
||||
S = Status(RealStatus, S.getName());
|
||||
S = Status::copyWithNewName(RealStatus, S.getName());
|
||||
}
|
||||
return S;
|
||||
}
|
||||
|
||||
Optional<std::string> RealFile::getRealPath() {
|
||||
if (RealName.empty())
|
||||
return llvm::None;
|
||||
return RealName;
|
||||
ErrorOr<std::string> RealFile::getName() {
|
||||
return RealName.empty() ? S.getName().str() : RealName;
|
||||
}
|
||||
|
||||
ErrorOr<std::unique_ptr<MemoryBuffer>>
|
||||
@@ -252,7 +251,7 @@ ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
|
||||
sys::fs::file_status RealStatus;
|
||||
if (std::error_code EC = sys::fs::status(Path, RealStatus))
|
||||
return EC;
|
||||
return Status(RealStatus, Path.str());
|
||||
return Status::copyWithNewName(RealStatus, Path.str());
|
||||
}
|
||||
|
||||
ErrorOr<std::unique_ptr<File>>
|
||||
@@ -304,7 +303,7 @@ public:
|
||||
if (Iter != llvm::sys::fs::directory_iterator()) {
|
||||
llvm::sys::fs::file_status S;
|
||||
std::error_code ErrorCode = llvm::sys::fs::status(Iter->path(), S, true);
|
||||
CurrentEntry = Status(S, Iter->path());
|
||||
CurrentEntry = Status::copyWithNewName(S, Iter->path());
|
||||
if (!EC)
|
||||
EC = ErrorCode;
|
||||
}
|
||||
@@ -318,7 +317,7 @@ public:
|
||||
} else {
|
||||
llvm::sys::fs::file_status S;
|
||||
std::error_code ErrorCode = llvm::sys::fs::status(Iter->path(), S, true);
|
||||
CurrentEntry = Status(S, Iter->path());
|
||||
CurrentEntry = Status::copyWithNewName(S, Iter->path());
|
||||
if (!EC)
|
||||
EC = ErrorCode;
|
||||
}
|
||||
@@ -1642,7 +1641,7 @@ static Status getRedirectedFileStatus(const Twine &Path, bool UseExternalNames,
|
||||
Status ExternalStatus) {
|
||||
Status S = ExternalStatus;
|
||||
if (!UseExternalNames)
|
||||
S = S.copyWithNewName(Path.str());
|
||||
S = Status::copyWithNewName(S, Path.str());
|
||||
S.IsVFSMapped = true;
|
||||
return S;
|
||||
}
|
||||
@@ -1658,7 +1657,7 @@ ErrorOr<Status> RedirectingFileSystem::status(const Twine &Path, Entry *E) {
|
||||
return S;
|
||||
} else { // directory
|
||||
auto *DE = cast<RedirectingDirectoryEntry>(E);
|
||||
return DE->getStatus().copyWithNewName(Path.str());
|
||||
return Status::copyWithNewName(DE->getStatus(), Path.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user