X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstat.cpp;h=c5bfb642ab92b65376dba5f7f13e4a10eb7a0d94;hp=3bfae74c348dc2429b135efc189878514c56d518;hb=1834fcf2465c77c387bc92df5529d8631abaffa5;hpb=a17d6ad286e19e2222ab8b6c9a762a83bf2c6c56 diff --git a/source/stat.cpp b/source/stat.cpp index 3bfae74..c5bfb64 100644 --- a/source/stat.cpp +++ b/source/stat.cpp @@ -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