summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-02-21 21:52:56 -0800
committerRyan Dahl <ry@tinyclouds.org>2010-02-21 21:53:35 -0800
commit4c8889bba2a06d77b8e5835e70e10e3f9b412d6f (patch)
treed52b7002af2cec21389515951fb591fee19bb45d
parent9acc8a686a45242c30f50e21d3166a1d4a933785 (diff)
downloadnode-new-4c8889bba2a06d77b8e5835e70e10e3f9b412d6f.tar.gz
Revert "Add fs.readdirSync()"
Doesn't work on Linux. This reverts commit 05d6da6c4af25fc417902ad1bbae9198e58ff37a.
-rw-r--r--src/node_file.cc29
-rw-r--r--test/mjsunit/test-readdir.js41
2 files changed, 19 insertions, 51 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 7cf12bc351..07f8ab5cec 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -10,8 +10,6 @@
#include <string.h>
#include <errno.h>
-#include <dirent.h>
-
namespace node {
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) {
HandleScope scope;
@@ -342,26 +336,9 @@ static Handle<Value> ReadDir(const Arguments& args) {
if (args[1]->IsFunction()) {
ASYNC_CALL(readdir, args[1], *path, 0 /*flags*/)
} else {
- struct dirent **eps;
- int n = scandir(*path, &eps, scandir_one, alphasort);
-
- 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));
- }
+ // TODO
+ return ThrowException(Exception::Error(
+ String::New("synchronous readdir() not yet supported.")));
}
}
diff --git a/test/mjsunit/test-readdir.js b/test/mjsunit/test-readdir.js
index 4ded485571..f740560a55 100644
--- a/test/mjsunit/test-readdir.js
+++ b/test/mjsunit/test-readdir.js
@@ -2,37 +2,28 @@ process.mixin(require("./common"));
var got_error = false;
-var files = ['a.js'
- , 'b'
- , 'cycles'
- , 'echo.js'
- , 'multipart.js'
- , 'nested-index'
- , 'print-chars.js'
- , 'test_ca.pem'
- , 'test_cert.pem'
- , 'test_key.pem'
- , 'throws_error.js'
- , 'x.txt'
- ];
-
-
-puts('readdirSync ' + fixturesDir);
-var f = fs.readdirSync(fixturesDir);
-p(f);
-assert.deepEqual(files, f.sort());
-
-
-puts("readdir " + fixturesDir);
-fs.readdir(fixturesDir, function (err, f) {
+fs.readdir(fixturesDir, function (err, files) {
if (err) {
puts("error");
got_error = true;
} else {
- p(f);
- assert.deepEqual(files, f.sort());
+ p(files);
+ assert.deepEqual(['a.js'
+ , 'b'
+ , 'cycles'
+ , 'echo.js'
+ , 'multipart.js'
+ , 'nested-index'
+ , 'print-chars.js'
+ , 'test_ca.pem'
+ , 'test_cert.pem'
+ , 'test_key.pem'
+ , 'throws_error.js'
+ , 'x.txt'
+ ], files.sort());
}
});
+puts("readdir " + fixturesDir);
process.addListener("exit", function () {
assert.equal(false, got_error);