Commit 0fc9a4c9 authored by Benjamin Chelli's avatar Benjamin Chelli

Refactor readDir to readdir to match nodejs File System native interface

parent 2e932a08
...@@ -37,7 +37,7 @@ s.connect(function(err){ ...@@ -37,7 +37,7 @@ s.connect(function(err){
if(err) throw err; if(err) throw err;
// display content in the console // display content in the console
console.log(files.map(function(v){return v.Filename})); console.log(files);
// close the connection // close the connection
s.close(); s.close();
......
...@@ -135,7 +135,7 @@ proto.close = function(){ ...@@ -135,7 +135,7 @@ proto.close = function(){
/* /*
* readDir * readdir
* ======= * =======
* *
* list the file / directory from the path provided: * list the file / directory from the path provided:
...@@ -147,7 +147,7 @@ proto.close = function(){ ...@@ -147,7 +147,7 @@ proto.close = function(){
* - close the directory * - close the directory
* *
*/ */
proto.readDir = function(path, cb){ proto.readdir = function(path, cb){
var connection = this; var connection = this;
// SMB2 open directory // SMB2 open directory
...@@ -158,7 +158,12 @@ proto.readDir = function(path, cb){ ...@@ -158,7 +158,12 @@ proto.readDir = function(path, cb){
if(err) cb && cb(err); if(err) cb && cb(err);
// SMB2 close directory // SMB2 close directory
else SMB2Request('close', file, connection, function(err){ else SMB2Request('close', file, connection, function(err){
cb && cb(err, files); cb && cb(
err
, files
.map(function(v){ return v.Filename }) // get the filename only
.filter(function(v){ return v!='.' && v!='..' }) // remove '.' and '..' values
);
}); });
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment