1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Resubmit FileSystem changes.

This was originall reverted due to some test failures in
ModuleCache and TestCompDirSymlink.  These issues have all
been resolved and the code now passes all tests.

Differential Revision: https://reviews.llvm.org/D30698

llvm-svn: 297300
This commit is contained in:
Zachary Turner 2017-03-08 17:56:08 +00:00
parent 658cbdf5ad
commit 28d9b5adef
2 changed files with 44 additions and 6 deletions

View File

@ -482,8 +482,10 @@ inline bool is_local(int FD) {
/// @brief Does status represent a directory?
///
/// @param Path The path to get the type of.
/// @param follow For symbolic links, indicates whether to return the file type
/// of the link itself, or of the target.
/// @returns A value from the file_type enumeration indicating the type of file.
file_type get_file_type(const Twine &Path, bool follow = true);
file_type get_file_type(const Twine &Path, bool Follow = true);
/// @brief Does status represent a directory?
///
@ -494,8 +496,8 @@ bool is_directory(file_status status);
/// @brief Is path a directory?
///
/// @param path Input path.
/// @param result Set to true if \a path is a directory, false if it is not.
/// Undefined otherwise.
/// @param result Set to true if \a path is a directory (after following
/// symlinks, false if it is not. Undefined otherwise.
/// @returns errc::success if result has been successfully set, otherwise a
/// platform-specific error_code.
std::error_code is_directory(const Twine &path, bool &result);
@ -516,8 +518,8 @@ bool is_regular_file(file_status status);
/// @brief Is path a regular file?
///
/// @param path Input path.
/// @param result Set to true if \a path is a regular file, false if it is not.
/// Undefined otherwise.
/// @param result Set to true if \a path is a regular file (after following
/// symlinks), false if it is not. Undefined otherwise.
/// @returns errc::success if result has been successfully set, otherwise a
/// platform-specific error_code.
std::error_code is_regular_file(const Twine &path, bool &result);
@ -531,8 +533,32 @@ inline bool is_regular_file(const Twine &Path) {
return Result;
}
/// @brief Does status represent a symlink file?
///
/// @param status A file_status previously returned from status.
/// @returns status_known(status) && status.type() == file_type::symlink_file.
bool is_symlink_file(file_status status);
/// @brief Is path a symlink file?
///
/// @param path Input path.
/// @param result Set to true if \a path is a symlink file, false if it is not.
/// Undefined otherwise.
/// @returns errc::success if result has been successfully set, otherwise a
/// platform-specific error_code.
std::error_code is_symlink_file(const Twine &path, bool &result);
/// @brief Simpler version of is_symlink_file for clients that don't need to
/// differentiate between an error and false.
inline bool is_symlink_file(const Twine &Path) {
bool Result;
if (is_symlink_file(Path, Result))
return false;
return Result;
}
/// @brief Does this status represent something that exists but is not a
/// directory, regular file, or symlink?
/// directory or regular file?
///
/// @param status A file_status previously returned from status.
/// @returns exists(s) && !is_regular_file(s) && !is_directory(s)

View File

@ -984,6 +984,18 @@ std::error_code is_regular_file(const Twine &path, bool &result) {
return std::error_code();
}
bool is_symlink_file(file_status status) {
return status.type() == file_type::symlink_file;
}
std::error_code is_symlink_file(const Twine &path, bool &result) {
file_status st;
if (std::error_code ec = status(path, st, false))
return ec;
result = is_symlink_file(st);
return std::error_code();
}
bool is_other(file_status status) {
return exists(status) &&
!is_regular_file(status) &&