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

Improved bctbx_directory_exists

parent fb4cc347
......@@ -393,7 +393,7 @@ 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);
BCTBX_PUBLIC bool_t 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 ).
......
......@@ -158,10 +158,9 @@ 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);
bool_t bctbx_directory_exists(const char *pathname) {
struct stat sb;
return (stat(pathname, &sb) == 0 && S_ISDIR(sb.st_mode));
}
#if !defined(_WIN32) && !defined(_WIN32_WCE)
......
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