7#if defined(_AIX) || defined(__sun__)
21#if __DCL_HAVE_ALLOC_DEBUG
22#undef __DCL_ALLOC_LEVEL
23#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
26#if __DCL_HAVE_THIS_FILE__
33#ifndef INVALID_HANDLE_VALUE
34#define INVALID_HANDLE_VALUE ((DIR*)-1)
41 memset(&__dirent, 0,
sizeof(__dirent));
44String Dir::Entry::name() const
48 return String(__dirent.cFileName);
57bool Dir::Entry::isDir()
const
59 return (__dirent.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
62bool Dir::Entry::isLink()
const
64 return (__dirent.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
67bool Dir::Entry::isDir()
const
69#if defined(_AIX) || defined(__sun__)
70 String path =
__path + name();
73 throw new IOException(path, errno);
75 return S_ISDIR(st.st_mode);
77 return __dirent.d_type == DT_DIR;
81bool Dir::Entry::isLink()
const
83#if defined(_AIX) || defined(__sun__)
84 String path =
__path + name();
87 throw new IOException(path, errno);
89 return S_ISLNK(st.st_mode);
91 return __dirent.d_type == DT_LNK;
96String Dir::Entry::toString() const
99 StringBuilder
r = name();
100 if (isDir() || isLink()) {
103 r +=
__T(
"directory");
107 r +=
__T(
"symbolic link");
120 catch (Exception* e) {
132 String path = _path.replace(
__T(
'\\'),
__T(
'/'));
133 if (!path.endsWith(
__T(
'/')))
134 path = path +
__T(
"/");
137 WIN32_FIND_DATAW findData;
138 HANDLE h = FindFirstFileW(path +
__T(
'*'), &findData);
140 throw new IOException(_path, GetLastError());
142 if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
143 throw new IOException(_path, ERROR_DIRECTORY);
146 if (
__stat(path, &st) != 0) {
147 throw new IOException(path, errno);
150 if (!S_ISDIR(st.st_mode)) {
151 throw new IOException(path, ENOTDIR);
167 if (!FindClose(handle))
168 throw new IOException(
__path, GetLastError());
170 if (closedir(handle))
171 throw new IOException(
__path, errno);
188 throw new IOException(
__path, EILSEQ);
191 DIR* handle = opendir(path);
192 if (handle ==
NULL) {
193 throw new IOException(
__path, errno);
199bool Dir::read(Dir::Entry& _entry)
__DCL_THROWS1(IOException*)
203 HANDLE h = FindFirstFileW(
__path +
__T(
'*'), &_entry.__dirent);
205 throw new IOException(
__path, GetLastError());
209 if (!FindNextFileW(
__handle, &_entry.__dirent)) {
210 if (GetLastError() == ERROR_NO_MORE_FILES)
213 throw new IOException(
__path, GetLastError());
220 struct dirent* ent = readdir(
__handle);
222 memcpy((
void*)&_entry.__dirent, ent,
sizeof(_entry.__dirent));
225#elif defined(__sun__)
228 _entry.__dirent.d_name[0] =
'\0';
231 else if (errno != 0) {
232 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 __lstat(const String &_path, struct stat *_buf)
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