3 This file is part of libmspfs
4 Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
12 #include <msp/core/except.h>
19 int stat(const Path &fn, struct stat &st)
21 return ::stat(fn.str().c_str(), &st);
24 struct stat stat(const Path &fn)
28 throw SystemError("stat failed", errno);
32 int lstat(const Path &fn, struct stat &st)
37 return ::lstat(fn.str().c_str(), &st);
41 struct stat lstat(const Path &fn)
45 throw SystemError("lstat failed", errno);
49 bool exists(const Path &path)
51 return access(path.str().c_str(), F_OK)==0;
54 bool is_reg(const Path &path)
58 return S_ISREG(st.st_mode);
62 bool is_dir(const Path &path)
66 return S_ISDIR(st.st_mode);
70 bool is_link(const Path &path)
76 if(lstat(path, st)==0)
77 return S_ISLNK(st.st_mode);