Commit 649a22e0 authored by Adrien Béraud's avatar Adrien Béraud

fileutils: add isDirectory

The method returns true if given path is a directory filesystem entry

Refs #68196

Change-Id: I983b23aec24e30321483b3f90d0ef9ccacbc515f
parent a3f9cd7b
......@@ -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;
......
......@@ -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,
......
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