1 |
|
|
#ifndef SRC_NODE_DIR_H_ |
2 |
|
|
#define SRC_NODE_DIR_H_ |
3 |
|
|
|
4 |
|
|
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
5 |
|
|
|
6 |
|
|
#include "node_file.h" |
7 |
|
|
|
8 |
|
|
namespace node { |
9 |
|
|
|
10 |
|
|
namespace fs_dir { |
11 |
|
|
|
12 |
|
|
// Needed to propagate `uv_dir_t`. |
13 |
|
|
class DirHandle : public AsyncWrap { |
14 |
|
|
public: |
15 |
|
|
static DirHandle* New(Environment* env, uv_dir_t* dir); |
16 |
|
|
~DirHandle() override; |
17 |
|
|
|
18 |
|
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args); |
19 |
|
|
static void Read(const v8::FunctionCallbackInfo<v8::Value>& args); |
20 |
|
|
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args); |
21 |
|
|
|
22 |
|
603 |
inline uv_dir_t* dir() { return dir_; } |
23 |
|
|
|
24 |
|
|
void MemoryInfo(MemoryTracker* tracker) const override; |
25 |
|
|
SET_MEMORY_INFO_NAME(DirHandle) |
26 |
|
|
SET_SELF_SIZE(DirHandle) |
27 |
|
|
|
28 |
|
|
DirHandle(const DirHandle&) = delete; |
29 |
|
|
DirHandle& operator=(const DirHandle&) = delete; |
30 |
|
|
DirHandle(const DirHandle&&) = delete; |
31 |
|
|
DirHandle& operator=(const DirHandle&&) = delete; |
32 |
|
|
|
33 |
|
|
private: |
34 |
|
|
DirHandle(Environment* env, v8::Local<v8::Object> obj, uv_dir_t* dir); |
35 |
|
|
|
36 |
|
|
// Synchronous close that emits a warning |
37 |
|
|
void GCClose(); |
38 |
|
|
|
39 |
|
|
uv_dir_t* dir_; |
40 |
|
|
// Multiple entries are read through a single libuv call. |
41 |
|
|
std::vector<uv_dirent_t> dirents_; |
42 |
|
|
bool closing_ = false; |
43 |
|
|
bool closed_ = false; |
44 |
|
|
}; |
45 |
|
|
|
46 |
|
|
} // namespace fs_dir |
47 |
|
|
|
48 |
|
|
} // namespace node |
49 |
|
|
|
50 |
|
|
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
51 |
|
|
|
52 |
|
|
#endif // SRC_NODE_DIR_H_ |