Node-SMB / marsaud-smb2

SMB2 Client
53 stars 46 forks source link

check path is Directory or file #53

Closed mogadanez closed 3 years ago

mogadanez commented 4 years ago

is it possible to check path is Directory or file ideally - readdir with advanced properties like dir|file, size, etc

koush commented 4 years ago

The information is there but it is scrubbed before being returned.

https://github.com/koush/marsaud-smb2/commit/308a33b3c05a43c1ebdfa9d8c998e85634784b29

PachVerb commented 4 years ago

The information is there but it is scrubbed before being returned.

https://github.com/koush/marsaud-smb2/commit/308a33b3c05a43c1ebdfa9d8c998e85634784b29 is this commit is your product? I want to use it on
my project

koush commented 4 years ago

yeah go ahead and use it

PachVerb commented 4 years ago

yeah go ahead and use it

Hi, I used him on the project and it worked well. But the returned file meta-information is a buffer buffer flow. How do you parse it to be readable? do you know? help

sachinraste commented 4 years ago

FIleName : readdir.js

When you modify the readdir.js you will get the parsed output. [{obj1},{obj2}]

NOTE :

//FileAttributes = 16 = Directory
//FileAttributes = 32 = File
var BigInt = require('../tools/bigint');
filesBatch.push(files.map(function (v) {
              // get the filename only
              v.CreationTime = convert(BigInt.fromBuffer(v.CreationTime).toNumber())
              v.LastAccessTime = convert(BigInt.fromBuffer(v.LastAccessTime).toNumber())
              v.LastWriteTime = convert(BigInt.fromBuffer(v.LastWriteTime).toNumber())
              v.ChangeTime = convert(BigInt.fromBuffer(v.ChangeTime).toNumber())
              v.EndofFile = v.EndofFile.toString()
              v.AllocationSize= BigInt.fromBuffer(v.AllocationSize).toNumber()
             return v;
            })
            .filter(function (v) {
              // remove '.' and '..' values
              return v.Filename !== '.' && v.Filename !== '..';
            })
        );
function convert(time) {
    var winTicks = 10000000;
    var uEpoch = 11644473600;
    var unixTime = time / winTicks - uEpoch;
    var utc = new Date(unixTime * 1000).toUTCString();
    return utc
  }
vdiez commented 3 years ago

this should now be possible with 0.17

Thanks @sachinraste for the idea

I think we can close this