mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-13 17:06:15 +00:00
Remove PathWithStatus.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184910 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
34b96d1576
commit
2c63b27e9f
@ -405,92 +405,6 @@ namespace sys {
|
|||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This class is identical to Path class except it allows you to obtain the
|
|
||||||
/// file status of the Path as well. The reason for the distinction is one of
|
|
||||||
/// efficiency. First, the file status requires additional space and the space
|
|
||||||
/// is incorporated directly into PathWithStatus without an additional malloc.
|
|
||||||
/// Second, obtaining status information is an expensive operation on most
|
|
||||||
/// operating systems so we want to be careful and explicit about where we
|
|
||||||
/// allow this operation in LLVM.
|
|
||||||
/// @brief Path with file status class.
|
|
||||||
class PathWithStatus : public Path {
|
|
||||||
/// @name Constructors
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// @brief Default constructor
|
|
||||||
PathWithStatus() : Path(), status(), fsIsValid(false) {}
|
|
||||||
|
|
||||||
/// @brief Copy constructor
|
|
||||||
PathWithStatus(const PathWithStatus &that)
|
|
||||||
: Path(static_cast<const Path&>(that)), status(that.status),
|
|
||||||
fsIsValid(that.fsIsValid) {}
|
|
||||||
|
|
||||||
/// This constructor allows construction from a Path object
|
|
||||||
/// @brief Path constructor
|
|
||||||
PathWithStatus(const Path &other)
|
|
||||||
: Path(other), status(), fsIsValid(false) {}
|
|
||||||
|
|
||||||
/// This constructor will accept a char* or std::string as a path. No
|
|
||||||
/// checking is done on this path to determine if it is valid. To
|
|
||||||
/// determine validity of the path, use the isValid method.
|
|
||||||
/// @brief Construct a Path from a string.
|
|
||||||
explicit PathWithStatus(
|
|
||||||
StringRef p ///< The path to assign.
|
|
||||||
) : Path(p), status(), fsIsValid(false) {}
|
|
||||||
|
|
||||||
/// This constructor will accept a character range as a path. No checking
|
|
||||||
/// is done on this path to determine if it is valid. To determine
|
|
||||||
/// validity of the path, use the isValid method.
|
|
||||||
/// @brief Construct a Path from a string.
|
|
||||||
explicit PathWithStatus(
|
|
||||||
const char *StrStart, ///< Pointer to the first character of the path
|
|
||||||
unsigned StrLen ///< Length of the path.
|
|
||||||
) : Path(StrStart, StrLen), status(), fsIsValid(false) {}
|
|
||||||
|
|
||||||
/// Makes a copy of \p that to \p this.
|
|
||||||
/// @returns \p this
|
|
||||||
/// @brief Assignment Operator
|
|
||||||
PathWithStatus &operator=(const PathWithStatus &that) {
|
|
||||||
static_cast<Path&>(*this) = static_cast<const Path&>(that);
|
|
||||||
status = that.status;
|
|
||||||
fsIsValid = that.fsIsValid;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Makes a copy of \p that to \p this.
|
|
||||||
/// @returns \p this
|
|
||||||
/// @brief Assignment Operator
|
|
||||||
PathWithStatus &operator=(const Path &that) {
|
|
||||||
static_cast<Path&>(*this) = static_cast<const Path&>(that);
|
|
||||||
fsIsValid = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Methods
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// This function returns status information about the file. The type of
|
|
||||||
/// path (file or directory) is updated to reflect the actual contents
|
|
||||||
/// of the file system.
|
|
||||||
/// @returns 0 on failure, with Error explaining why (if non-zero),
|
|
||||||
/// otherwise returns a pointer to a FileStatus structure on success.
|
|
||||||
/// @brief Get file status.
|
|
||||||
const FileStatus *getFileStatus(
|
|
||||||
bool forceUpdate = false, ///< Force an update from the file system
|
|
||||||
std::string *Error = 0 ///< Optional place to return an error msg.
|
|
||||||
) const;
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Data
|
|
||||||
/// @{
|
|
||||||
private:
|
|
||||||
mutable FileStatus status; ///< Status information.
|
|
||||||
mutable bool fsIsValid; ///< Whether we've obtained it or not
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -332,26 +332,6 @@ Path::isRegularFile() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FileStatus *
|
|
||||||
PathWithStatus::getFileStatus(bool update, std::string *ErrStr) const {
|
|
||||||
if (!fsIsValid || update) {
|
|
||||||
struct stat buf;
|
|
||||||
if (0 != stat(path.c_str(), &buf)) {
|
|
||||||
MakeErrMsg(ErrStr, path + ": can't get status of file");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
status.fileSize = buf.st_size;
|
|
||||||
status.modTime.fromEpochTime(buf.st_mtime);
|
|
||||||
status.mode = buf.st_mode;
|
|
||||||
status.user = buf.st_uid;
|
|
||||||
status.group = buf.st_gid;
|
|
||||||
status.isDir = S_ISDIR(buf.st_mode);
|
|
||||||
status.isFile = S_ISREG(buf.st_mode);
|
|
||||||
fsIsValid = true;
|
|
||||||
}
|
|
||||||
return &status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool AddPermissionBits(const Path &File, int bits) {
|
static bool AddPermissionBits(const Path &File, int bits) {
|
||||||
// Get the umask value from the operating system. We want to use it
|
// Get the umask value from the operating system. We want to use it
|
||||||
// when changing the file's permissions. Since calling umask() sets
|
// when changing the file's permissions. Since calling umask() sets
|
||||||
|
@ -245,35 +245,6 @@ Path::isRegularFile() const {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FileStatus *
|
|
||||||
PathWithStatus::getFileStatus(bool update, std::string *ErrStr) const {
|
|
||||||
if (!fsIsValid || update) {
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA fi;
|
|
||||||
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) {
|
|
||||||
MakeErrMsg(ErrStr, "getStatusInfo():" + std::string(path) +
|
|
||||||
": Can't get status: ");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
status.fileSize = fi.nFileSizeHigh;
|
|
||||||
status.fileSize <<= sizeof(fi.nFileSizeHigh)*8;
|
|
||||||
status.fileSize += fi.nFileSizeLow;
|
|
||||||
|
|
||||||
status.mode = fi.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
|
|
||||||
status.user = 9999; // Not applicable to Windows, so...
|
|
||||||
status.group = 9999; // Not applicable to Windows, so...
|
|
||||||
|
|
||||||
ULARGE_INTEGER ui;
|
|
||||||
ui.LowPart = fi.ftLastWriteTime.dwLowDateTime;
|
|
||||||
ui.HighPart = fi.ftLastWriteTime.dwHighDateTime;
|
|
||||||
status.modTime.fromWin32Time(ui.QuadPart);
|
|
||||||
|
|
||||||
status.isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
|
||||||
fsIsValid = true;
|
|
||||||
}
|
|
||||||
return &status;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Path::makeReadableOnDisk(std::string* ErrMsg) {
|
bool Path::makeReadableOnDisk(std::string* ErrMsg) {
|
||||||
// All files are readable on Windows (ignoring security attributes).
|
// All files are readable on Windows (ignoring security attributes).
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user