DCL 4.0
Loading...
Searching...
No Matches
Dir.h
Go to the documentation of this file.
1#ifndef __DCL_DIR_H__
2#define __DCL_DIR_H__
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/Config.h>
6#endif
7
8#if __DCL_WINDOWS
9 #ifndef _WINDOWS_
10 #error "Required windows.h, See dcl/_windows.h"
11 #endif
12#else
13 #include <dirent.h>
14#endif
15
16#ifndef __DCL_OBJECT_H__
17#include <dcl/Object.h>
18#endif
19#ifndef __DCL_STRING_H__
20#include <dcl/String.h>
21#endif
22#ifndef __DCL_EXCEPTION_H__
23#include <dcl/Exception.h>
24#endif
25
26__DCL_BEGIN_NAMESPACE
27
29
37class DCLCAPI Dir : public Object
38{
40public:
41#if __DCL_WINDOWS
42 typedef HANDLE HandleType;
43#else
44 typedef DIR* HandleType;
45#endif
46
52 class DCLCAPI Entry
53#if __DCL_WINDOWS
54 : public WIN32_FIND_DATAW
55#else
56 : public dirent
57#endif
58 {
59 public:
63 bool isDir() const;
64
69 bool isLink() const;
70
74 Entry();
75
83
84 String name() const
86
90 String toString() const;
91 };
92
97 virtual ~Dir();
98
103 Dir(const String& _path)
105
109 void close()
111
115 void rewind()
117
131 bool read(Entry& _buf) __DCL_THROWS1(IOException*);
132
137 const String& path() const { return __path; }
138
139protected:
140 HandleType __handle;
141 String __path;
142};
143
144#if __DCL_WINDOWS
145inline bool Dir::Entry::isDir() const
146{
147 return (this->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
148}
149
150inline bool Dir::Entry::isLink() const
151{
152 return (this->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
153}
154#else
155inline bool Dir::Entry::isDir() const
156{
157 return this->d_type == DT_DIR;
158}
159
160inline bool Dir::Entry::isLink() const
161{
162 return this->d_type == DT_LNK;
163}
164#endif
165
166__DCL_END_NAMESPACE
167
168#endif // __DCL_DIR_H__
#define DCLCAPI
Definition Config.h:100
#define __DCL_THROWS1(e)
Definition Config.h:167
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:210
if(!__handle->open(bs, bs.length()))
String __path
Definition Dir.h:141
HandleType __handle
Definition Dir.h:140
Object()
Definition Object.cpp:183
virtual String toString() const
Definition Object.cpp:187