From 92010eeb2c935e27835f4441a4f7cadd19acf8d3 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 17 May 2014 14:21:19 -0400 Subject: [PATCH] Path - Implemented Path::is_link, although it doesn't work. Why? --- src/Path.cpp | 11 +++++++++++ src/Path.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/Path.cpp b/src/Path.cpp index 8423c7c33..f54f721d9 100644 --- a/src/Path.cpp +++ b/src/Path.cpp @@ -176,6 +176,17 @@ bool Path::is_absolute () const return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Path::is_link () const +{ + struct stat s = {0}; + if (! stat (_data.c_str (), &s) && + s.st_mode & S_IFLNK) + return true; + + return false; +} + //////////////////////////////////////////////////////////////////////////////// bool Path::readable () const { diff --git a/src/Path.h b/src/Path.h index 1696c54d6..f595991ff 100644 --- a/src/Path.h +++ b/src/Path.h @@ -49,6 +49,7 @@ public: bool exists () const; bool is_directory () const; bool is_absolute () const; + bool is_link () const; bool readable () const; bool writable () const; bool executable () const;