Add readlink method in filesystem API 88/140888/1
authorSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 27 Jul 2017 05:15:21 +0000 (14:15 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 27 Jul 2017 05:21:28 +0000 (14:21 +0900)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: I86dda70ea0201a0a2f4ec4b0bfd58a5af86e9ae0

include/klay/filesystem.h
src/filesystem.cpp

index 5b5282a917a28172299cf390dce85bf95b0d3daa..3c62f048f42657e57686e35abbe87ba7850a842a 100644 (file)
@@ -112,6 +112,8 @@ public:
        void chown(uid_t uid, gid_t gid, bool recursive = false);
        void chmod(mode_t mode, bool recursive = false);
 
+       const std::string readlink() const;
+
        const std::string& getPath() const
        {
                return path;
index 7becd1dec17ac12362d8cce55bceb8cc705148a8..5fb0f199c5dc0988d74a491fa0a1e36c15c59a33 100644 (file)
@@ -381,6 +381,15 @@ void File::chmod(mode_t mode, bool recursive)
        }
 }
 
+const std::string File::readlink() const
+{
+       char buf[PATH_MAX];
+       if (::readlink(path.c_str(), buf, PATH_MAX) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
+       return buf;
+}
+
 void File::lock() const
 {
        if (::flock(descriptor, LOCK_EX) == -1) {