Commit 0be24899 authored by wescoeur's avatar wescoeur

start/end options are supported by writable/readable streams.

parent a9d7fd11
......@@ -8,12 +8,19 @@ const requestAsync = Bluebird.promisify(request)
const maxPacketSize = 0x00010000
class SmbReadableStream extends Readable {
constructor (connection, file, options) {
constructor (connection, file, options = {}) {
super(options)
const {
start = 0,
end,
encoding
} = options
this.connection = connection
this.encoding = options && options.encoding
this.encoding = encoding
this.file = file
this.offset = new Bigint(8)
this.offset = new Bigint(8, start)
let fileLength = 0
for (let i = 0; i < file.EndofFile.length; i++) {
......@@ -21,6 +28,10 @@ class SmbReadableStream extends Readable {
}
this.fileLength = fileLength
this.wait = false
if (end >= 0 && end < fileLength) {
this.fileLength = end + 1
}
}
async _read (size) {
......
......@@ -8,12 +8,18 @@ const requestAsync = Bluebird.promisify(request)
const maxPacketSize = new Bigint(8, 0x00010000 - 0x71)
class SmbWritableStream extends Writable {
constructor (connection, file, options) {
constructor (connection, file, options = {}) {
super(options)
const {
encoding = 'utf8',
start = 0
} = options
this.connection = connection
this.encoding = options.encoding || 'utf8'
this.encoding = encoding
this.file = file
this.offset = new Bigint(8)
this.offset = new Bigint(8, start)
}
async _write (chunk, encoding, next) {
......
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