fs module
static void ReadDir(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(env->isolate());
node::Utf8Value path(args[0]);
if (args[1]->IsFunction()) {
ASYNC_CALL(readdir, args[1], *path, 0 )
} else {
SYNC_CALL(readdir, *path, *path, 0 )
char* namebuf = static_cast<char*>(SYNC_REQ.ptr);
uint32_t nnames = SYNC_REQ.result;
Local<Array> names = Array::New(env->isolate(), nnames);
for (uint32_t i = 0; i < nnames; ++i) {
names->Set(i, String::NewFromUtf8(env->isolate(), namebuf));
namebuf += strlen(namebuf) + 1;
}
args.GetReturnValue().Set(names);
}
}