From 559b8fbffcb4b6ed8427d732a7325740d85903a6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 7 Nov 2010 04:36:50 +0000 Subject: Add method for checking if a path is a symbolic link. llvm-svn: 118367 --- llvm/lib/System/Unix/Path.inc | 9 +++++++++ llvm/lib/System/Win32/Path.inc | 5 +++++ 2 files changed, 14 insertions(+) (limited to 'llvm/lib/System') diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index d5b7542757d..5ee3adc4d2d 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -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); diff --git a/llvm/lib/System/Win32/Path.inc b/llvm/lib/System/Win32/Path.inc index 2ead80127b3..4db7696b49e 100644 --- a/llvm/lib/System/Win32/Path.inc +++ b/llvm/lib/System/Win32/Path.inc @@ -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. -- cgit v1.2.3