18#if __DCL_HAVE_ALLOC_DEBUG
19#undef __DCL_ALLOC_LEVEL
20#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
30#ifndef INVALID_HANDLE_VALUE
31#define INVALID_HANDLE_VALUE ((DIR*)-1)
40 sizeof(WIN32_FIND_DATAW)
47String Dir::Entry::name() const
51 return String(this->cFileName);
57String Dir::Entry::toString() const
60 StringBuilder
r = name();
62 if (isDir() || isLink()) {
65 r +=
__T(
"directory");
69 r +=
__T(
"symbolic link");
82 catch (Exception* e) {
94 String path = _path.replace(
__T(
'\\'),
__T(
'/'));
95 if (!path.endsWith(
__T(
'/')))
96 path = path +
__T(
"/");
99 WIN32_FIND_DATAW findData;
100 HANDLE h = FindFirstFileW(path +
__T(
'*'), &findData);
102 throw new IOException(_path, GetLastError());
104 if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
105 throw new IOException(_path, ERROR_DIRECTORY);
108 if (
__stat(path, &st) == -1)
109 throw new IOException(path, errno);
111 if (!S_ISDIR(st.st_mode))
112 throw new IOException(path, ENOTDIR);
127 if (!FindClose(handle))
128 throw new IOException(
__path, GetLastError());
130 if (closedir(handle))
131 throw new IOException(
__path, errno);
148 throw new IOException(
__path, EILSEQ);
151 DIR* handle = opendir(path);
152 if (handle ==
NULL) {
153 throw new IOException(
__path, errno);
163 HANDLE h = FindFirstFileW(
__path +
__T(
'*'), &_buf);
165 throw new IOException(
__path, GetLastError());
169 if (!FindNextFileW(
__handle, &_buf)) {
170 if (GetLastError() == ERROR_NO_MORE_FILES)
173 throw new IOException(
__path, GetLastError());
182 memcpy((
void*) &_buf,
result,
sizeof(
struct dirent));
184 else if (errno != 0 ) {
185 throw new IOException(
__path, errno);
__DCL_BEGIN_NAMESPACE String __mbstostr(const char *_mbs, size_t _nmbs) __DCL_THROWS1(CharsetConvertException *)
#define STRTOMBS(str, mbs)
DCLCAPI int __stat(const String &_path, struct stat *_buf)
#define INVALID_HANDLE_VALUE
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
virtual String toString() const