diff --git a/src/fileutils.cpp b/src/fileutils.cpp index 1b66b332ca4cd53cd203c88bf495137cb74dd5d0..c6c40bf84012686e7a2df3f509f987a1af7d56fd 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -214,6 +214,14 @@ expand_path(const std::string &path) #endif } +bool isDirectory(const std::string& path) +{ + struct stat s; + if (stat(path.c_str(), &s) == 0) + return s.st_mode & S_IFDIR; + return false; +} + bool isDirectoryWritable(const std::string &directory) { return access(directory.c_str(), W_OK) == 0; diff --git a/src/fileutils.h b/src/fileutils.h index 192fba01223acec7e42e54ae82fae53cca660bdb..d784e7b3c8e1dfbaf146367341211b3d95160acc 100644 --- a/src/fileutils.h +++ b/src/fileutils.h @@ -67,6 +67,8 @@ namespace ring { namespace fileutils { bool recursive_mkdir(const std::string& path); #endif + bool isDirectory(const std::string& path); + /** * Read content of the directory. * The result is a list of full paths of files in the directory,