1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Add method for checking if a path is a symbolic link.

llvm-svn: 118367
This commit is contained in:
Rafael Espindola 2010-11-07 04:36:50 +00:00
parent 877bb5ba4b
commit 49a9710db0
3 changed files with 20 additions and 0 deletions

View File

@ -373,6 +373,12 @@ namespace sys {
/// @brief Determins if the path is a directory in the file system.
bool isDirectory() const;
/// This function determines if the path name refences an
/// existing symbolic link.
/// @returns true if the pathname references an existing symlink.
/// @brief Determins if the path is a symlink in the file system.
bool isSymLink() const;
/// This function determines if the path name references a readable file
/// or directory in the file system. This function checks for
/// the existence and readability (by the current program) of the file

View File

@ -433,6 +433,15 @@ Path::isDirectory() const {
return ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false;
}
bool
Path::isSymLink() const {
struct stat buf;
if (0 != lstat(path.c_str(), &buf))
return false;
return S_ISLNK(buf.st_mode);
}
bool
Path::canRead() const {
return 0 == access(path.c_str(), R_OK);

View File

@ -350,6 +350,11 @@ Path::isDirectory() const {
(attr & FILE_ATTRIBUTE_DIRECTORY);
}
bool
Path::isSymLink() const {
return false;
}
bool
Path::canRead() const {
// FIXME: take security attributes into account.