Commit d463f22b authored by Benjamin Chelli's avatar Benjamin Chelli

Refactor readFile to match nodejs File System native interface

parent 0fc9a4c9
......@@ -183,11 +183,16 @@ proto.readdir = function(path, cb){
* - close the file
*
*/
proto.readFile = function(path, cb){
proto.readFile = function(filename, options, cb){
var connection = this;
if(typeof options == 'function'){
cb = options;
options = {};
}
// SMB2 open file
SMB2Request('open', {path:dest}, connection, function(err, file){
SMB2Request('open', {path:filename}, connection, function(err, file){
if(err) cb && cb(err);
// SMB2 read file content
else {
......@@ -222,7 +227,7 @@ proto.readFile = function(path, cb){
createPackets();
if(nbRemainingPackets==0 && offset.ge(fileLength)) {
SMB2Request('close', file, connection, function(err){
cb && cb(err, result);
cb && cb(err, result.toString());
})
}
}
......
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