]> git.tdb.fi Git - libs/core.git/blobdiff - source/stat.cpp
New functions in utils.h: readlink realpath
[libs/core.git] / source / stat.cpp
index 3bfae74c348dc2429b135efc189878514c56d518..c5bfb642ab92b65376dba5f7f13e4a10eb7a0d94 100644 (file)
@@ -29,6 +29,23 @@ struct stat stat(const Path &fn)
        return st;
 }
 
+int lstat(const Path &fn, struct stat &st)
+{
+#ifdef WIN32
+       return stat(fn, st);
+#else
+       return ::lstat(fn.str().c_str(), &st);
+#endif
+}
+
+struct stat lstat(const Path &fn)
+{
+       struct stat st;
+       if(lstat(fn, st)==-1)
+               throw SystemError("lstat failed", errno);
+       return st;
+}
+
 bool exists(const Path &path)
 {
        return access(path.str().c_str(), F_OK)==0;
@@ -50,5 +67,13 @@ bool is_dir(const Path &path)
        return false;
 }
 
+bool is_link(const Path &path)
+{
+       struct stat st;
+       if(lstat(path, st)==0)
+               return S_ISLNK(st.st_mode);
+       return false;
+}
+
 } // namespace FS
 } // namespace Msp