lib/misc/stat_fns.h
changeset 0 6f7a81934006
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/misc/stat_fns.h	Wed Jan 16 22:39:43 2008 +0100
@@ -0,0 +1,31 @@
+#ifndef VMAILMGR__STAT_FNS__H__
+#define VMAILMGR__STAT_FNS__H__
+
+#include <sys/stat.h>
+#include <unistd.h>
+
+inline bool is_exist(const char* filename)
+{
+  struct stat buf;
+  return !stat(filename, &buf);
+}
+
+inline bool is_dir(const char* filename)
+{
+  struct stat buf;
+  return !stat(filename, &buf) && S_ISDIR(buf.st_mode);
+}
+
+inline bool is_symlink(const char* filename)
+{
+  struct stat buf;
+  return !lstat(filename, &buf) && S_ISLNK(buf.st_mode);
+}
+
+inline bool is_file(const char* filename)
+{
+  struct stat buf;
+  return !stat(filename, &buf) && S_ISREG(buf.st_mode);
+}
+
+#endif