"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/tar/lib/buffer-entry.js" (7 Feb 2017, 804 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // just like the Entry class, but it buffers the contents
    2 //
    3 // XXX It would be good to set a maximum BufferEntry filesize,
    4 // since it eats up memory.  In normal operation,
    5 // these are only for long filenames or link names, which are
    6 // rarely very big.
    7 
    8 module.exports = BufferEntry
    9 
   10 var inherits = require("inherits")
   11   , Entry = require("./entry.js")
   12 
   13 function BufferEntry () {
   14   Entry.apply(this, arguments)
   15   this._buffer = new Buffer(this.props.size)
   16   this._offset = 0
   17   this.body = ""
   18   this.on("end", function () {
   19     this.body = this._buffer.toString().slice(0, -1)
   20   })
   21 }
   22 
   23 inherits(BufferEntry, Entry)
   24 
   25 // collect the bytes as they come in.
   26 BufferEntry.prototype.write = function (c) {
   27   c.copy(this._buffer, this._offset)
   28   this._offset += c.length
   29   Entry.prototype.write.call(this, c)
   30 }