Commit 279ee7c9 authored by Julien Fontanet's avatar Julien Fontanet Committed by GitHub

chore(getSize): rewrite in ES5 (#24)

parent 869ff72d
var BigInt = require('../tools/bigint');
var request = require('../tools/smb2-forge').request;
module.exports = function getSize(path, cb) {
var connection = this;
request('open', { path: path }, connection, function(err, file) {
if (err != null) {
return cb(err);
}
request('close', file, connection, function() {
cb(null, BigInt.fromBuffer(file.EndofFile).toNumber());
});
});
};
import { request } from '../tools/smb2-forge';
export default function(path, cb) {
request('open', { path }, this, (err, file) => {
if (err) {
if (err.code === 'STATUS_OBJECT_NAME_NOT_FOUND') {
err.code = 'ENOENT';
}
cb(err);
} else {
let fileLength = 0;
for (let i = 0; i < file.EndofFile.length; i++) {
fileLength += file.EndofFile[i] * Math.pow(2, i * 8);
}
cb(null, fileLength);
}
});
}
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