lib/misc/stat_fns.h
author "Tomas Zeman <tzeman@volny.cz>"
Sun, 20 Jan 2008 00:22:25 +0100
changeset 3 3d1d327cfa68
parent 0 6f7a81934006
permissions -rw-r--r--
vmailmgr-0.97

#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