diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-07 04:36:50 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-07 04:36:50 +0000 |
commit | 9e07a149b079a28916cdd9d70849cd42344b54d0 (patch) | |
tree | 7205534636d5183308a21127b3ac5f82b62e56ae /lib | |
parent | 187d8339dbc0530850e54a86edf36f1a865a5823 (diff) | |
download | external_llvm-9e07a149b079a28916cdd9d70849cd42344b54d0.zip external_llvm-9e07a149b079a28916cdd9d70849cd42344b54d0.tar.gz external_llvm-9e07a149b079a28916cdd9d70849cd42344b54d0.tar.bz2 |
Add method for checking if a path is a symbolic link.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118367 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/System/Unix/Path.inc | 9 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index d5b7542..5ee3adc 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -434,6 +434,15 @@ Path::isDirectory() const { } 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); } diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index 2ead801..4db7696 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -351,6 +351,11 @@ Path::isDirectory() const { } bool +Path::isSymLink() const { + return false; +} + +bool Path::canRead() const { // FIXME: take security attributes into account. DWORD attr = GetFileAttributes(path.c_str()); |