Skip to content

Commit

Permalink
Add st.blksize and st.blocks (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager authored Nov 18, 2022
1 parent 9035652 commit f5f0085
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ module.exports = class RAM extends RandomAccess {
}

_stat (req) {
req.callback(null, { size: this.length })
const st = {
size: this.length,
blksize: this.pageSize,
blocks: 0
}

for (let i = 0; i < this.buffers.length; i++) {
if (this.buffers[i]) st.blocks += this.buffers[i].byteLength / 512
}

req.callback(null, st)
}

_write (req) {
Expand Down Expand Up @@ -133,7 +143,7 @@ module.exports = class RAM extends RandomAccess {
const ram = new RAM()
ram.length = this.length
ram.pageSize = this.pageSize
ram.buffers = this.buffers.map((buffer) => Buffer.from(buffer))
ram.buffers = this.buffers.map((buffer) => b4a.from(buffer))
return ram
}
}

0 comments on commit f5f0085

Please sign in to comment.