|
@ -10,8 +10,6 @@ |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
#include <errno.h> |
|
|
#include <errno.h> |
|
|
|
|
|
|
|
|
#include <dirent.h> |
|
|
|
|
|
|
|
|
|
|
|
namespace node { |
|
|
namespace node { |
|
|
|
|
|
|
|
|
using namespace v8; |
|
|
using namespace v8; |
|
@ -326,10 +324,6 @@ static Handle<Value> SendFile(const Arguments& args) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static inline int scandir_one(struct dirent *unused) { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Handle<Value> ReadDir(const Arguments& args) { |
|
|
static Handle<Value> ReadDir(const Arguments& args) { |
|
|
HandleScope scope; |
|
|
HandleScope scope; |
|
|
|
|
|
|
|
@ -342,26 +336,9 @@ static Handle<Value> ReadDir(const Arguments& args) { |
|
|
if (args[1]->IsFunction()) { |
|
|
if (args[1]->IsFunction()) { |
|
|
ASYNC_CALL(readdir, args[1], *path, 0 /*flags*/) |
|
|
ASYNC_CALL(readdir, args[1], *path, 0 /*flags*/) |
|
|
} else { |
|
|
} else { |
|
|
struct dirent **eps; |
|
|
// TODO
|
|
|
int n = scandir(*path, &eps, scandir_one, alphasort); |
|
|
return ThrowException(Exception::Error( |
|
|
|
|
|
String::New("synchronous readdir() not yet supported."))); |
|
|
if ( n >= 0) { |
|
|
|
|
|
int cnt; |
|
|
|
|
|
char *name; |
|
|
|
|
|
|
|
|
|
|
|
Local<Array> res = Array::New(n); |
|
|
|
|
|
|
|
|
|
|
|
for(cnt = 0; cnt < n; ++cnt) { |
|
|
|
|
|
name = eps[cnt]->d_name; |
|
|
|
|
|
|
|
|
|
|
|
if (name [0] != '.') { |
|
|
|
|
|
res->Set(Integer::New(cnt), String::New(name)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return scope.Close(res); |
|
|
|
|
|
} else { |
|
|
|
|
|
return ThrowException(errno_exception(errno)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|