lib/misc/stat_fns.h
author "Tomas Zeman <tzeman@volny.cz>"
Wed, 16 Jan 2008 22:39:43 +0100
changeset 0 6f7a81934006
permissions -rw-r--r--
Imported vmailmgr-0.96.9

#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