How can I check in NodeJS with samba if a path is a file or a directory?
I've the following folder structure:
folder/test
|
|-file1.txt
|-directoryA
|
|-image.jpg
I want to obtain a list of files like this: folder/test/file1.txt folder/test/directoryA/image.jpg
If I use fs I can make it with something like this:
fs.readdir(sourceDir, function(err, files){
if (err) {
Logger.error('readDir', '# Error reading sourceDir: ' + sourceDir);
throw err;
}
for (var i=0; i < files.length; i++) {
Logger.debug('readDir',sourceDir + ' => ' + files[i]);
}
files.map(function (file) {
return path.join(sourceDir, file);
}).filter(function (file) {
return fs.statSync(file).isFile();
}).forEach(function (file) {
var extname = path.extname(file);
Logger.debug('readDir','Working on ' + file + ' (' + extname + ')');
});
});
The problem is that I've to use samba and use smb2 library or something like that and this method doesn't exist:
fs.statSync(file).isFile();
How could I solve it?
via rudy 89
No comments:
Post a Comment