22 #include <sys/types.h>
31 if ((path==0) || (*path==0))
return false;
33 const char* part = path;
37 part = strchr(part+1,
'/');
43 subname.append(path, part - path);
46 if (stat(subname.c_str(), &buf) < 0) {
47 if (::
mkdir(subname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
return false;
49 if (!S_ISDIR(buf.st_mode)) {
50 EOUT(
"Existing path %s is not a directory", subname.c_str());
62 if (!fmask || (*fmask==0))
return nullptr;
65 const char* fname =
nullptr;
67 const char* slash = strrchr(fmask,
'/');
73 pathname.assign(fmask, slash - fmask + 1);
77 struct dirent **namelist;
78 int len = scandir(pathname.c_str(), &namelist, 0, alphasort);
79 if (len < 0)
return nullptr;
84 for (
int n=0;n<len;n++) {
85 const char* item = namelist[n]->d_name;
88 if ((item==0) || (*item ==
'.'))
continue;
90 if ((fname==0) || (fnmatch(fname, item, FNM_NOESCAPE)==0)) {
91 std::string fullitemname;
92 if (slash) fullitemname += pathname;
94 if (stat(fullitemname.c_str(), &buf)!=0)
continue;
96 if ((select_files && !S_ISDIR(buf.st_mode) && (access(fullitemname.c_str(), R_OK)==0)) ||
97 (!select_files && S_ISDIR(buf.st_mode) && (access(fullitemname.c_str(), R_OK | X_OK)==0))) {
virtual bool mkdir(const char *path)
virtual Object * fmatch(const char *fmask, bool select_files=true)
Produce list of files, object must be explicitly destroyed with ref.Destroy call One could decide if ...
Base class for most of the DABC classes.