Commit fb4cc347 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added method to know if dir exists

parent 7df8b5ca
......@@ -390,6 +390,11 @@ BCTBX_PUBLIC char *bctbx_basename(const char *path);
**/
BCTBX_PUBLIC int bctbx_file_exist(const char *pathname);
/**
* Tests if a directory with given pathname exists. Return 0 if yes, -1 otherwise.
**/
BCTBX_PUBLIC int bctbx_directory_exists(const char *pathname);
/**
* @brief return a timeSpec structure(sec and nsec) containing current time(WARNING: there is no guarantees it is UTC ).
* The time returned may refers to UTC or last boot.
......
......@@ -158,6 +158,12 @@ int bctbx_file_exist(const char *pathname) {
return access(pathname,F_OK);
}
int bctbx_directory_exists(const char *pathname) {
struct stat status;
stat(pathname, &status);
return (status.st_mode & S_IFDIR);
}
#if !defined(_WIN32) && !defined(_WIN32_WCE)
/* Use UNIX inet_aton method */
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment