47#define _XOPEN_SOURCE 600
54#ifndef _XOPEN_SOURCE_EXTENDED
55#define _XOPEN_SOURCE_EXTENDED
58#include <ucommon-config.h>
96 if(!CreateDirectory(path, NULL))
113 if(mkdir(path, (
long)attr | xmask))
123 if(!RemoveDirectory(path))
137 if(!SetCurrentDirectory(
prefix))
151 if(!GetCurrentDirectory((DWORD)size,
prefix))
154 if(getcwd(
prefix, size) == NULL)
163 size_t len = strlen(fname) + 4;
169 DWORD attr = GetFileAttributes(fname);
170 if( (attr == (DWORD)~0l) || !(attr & FILE_ATTRIBUTE_DIRECTORY) )
172#ifdef CCXX_EXCEPTIONS
175#ifdef COMMON_STD_EXCEPTION
177 throw(DirException(
String(fname) +
": failed"));
182 path = (
char *)_malloca(len + 1);
184 snprintf(path, len + 1,
"%s", fname);
185#ifdef CCXX_EXCEPTIONS
188#ifdef COMMON_STD_EXCEPTION
190 throw(DirException(
String(fname) +
": failed"));
193 if (!path || !path[0])
196 hDir = FindFirstFile(path, &fdata);
198 name = fdata.cFileName;
199 memcpy(&data, &fdata,
sizeof(fdata));
203 dir = opendir(fname);
204#ifdef CCXX_EXCEPTIONS
207#ifdef COMMON_STD_EXCEPTION
209 throw(DirException(
String(fname) +
": failed"));
238 memcpy(&data, &fdata,
sizeof(data));
239 name = fdata.cFileName;
272 return entry->d_name;
279 char *retname = name;
287 if(FindNextFile(hDir, &data))
288 name = data.cFileName;
304 return entry->d_name;
336 while(NULL != (cp = strchr(
path,
'\\')))
377 fpath = strrchr(
path,
'/');
384 if(!strcmp(fpath,
"."))
387 if(!strcmp(fpath,
".."))
405 cp = strrchr(
path,
'/');
413 snprintf(cp + 1,
sizeof(
path) - strlen(
path) - 2,
"%s", name);
415 if(::stat(
path, &ino))
426 if((ino.st_mode & S_IFMT) == S_IFDIR)
virtual bool filter(const char *file, struct stat *ino)
Virtual method to filter results.
char * getPath(void)
Extract the next full pathname from the directory walk.
DirTree(const char *prefix, unsigned maxdepth)
Construct a directory tree walk starting at the specified prefix.
void close(void)
Close the directory path.
unsigned perform(const char *prefix)
This is used to step through the filter virtual for an entire subtree, and is used for cases where a ...
void open(const char *prefix)
Open a directory tree path.
A low level portable directory class.
Dir(const char *name=NULL)
const char * getName(void)
static bool create(const char *path, Attr attr=attrGroup)
static bool getPrefix(char *path, size_t size=256)
void open(const char *name)
char save_space[sizeof(struct dirent)+256+1]
static bool remove(const char *path)
static bool setPrefix(const char *path)
static Throw getException(void)
Get exception mode of the current thread.
@ throwException
throw an object relative to error
@ throwObject
throw object that cause error (throw this)
A copy-on-write string class that operates by reference count.
Convenience class for directories.
void open(const char *path)
Open a directory path for reading.
void close(void)
Close and release directory object.
Export interfaces for library interfaces.
Common C++ thread class and sychronization objects.
GNU Common C++ exception model base classes.
Files and dynamic loader services.
bool canAccess(const char *path)
char * addString(char *target, size_t size, const char *str)
bool isDir(const char *path)