SILENT KILLERPanel

Current Path: > > usr > lib > node_modules > npm > > node_modules > tar > lib >


Operation   : Linux host59.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
Software     : Apache
Server IP    : 198.54.126.42 | Your IP: 216.73.216.38
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //usr/lib/node_modules/npm//node_modules/tar/lib/

NameTypeSizeLast ModifiedActions
buffer.js File 283 bytes March 10 2021 14:36:37.
create.js File 2374 bytes March 10 2021 14:36:37.
extract.js File 2824 bytes March 10 2021 14:36:37.
header.js File 9044 bytes March 10 2021 14:36:37.
high-level-opt.js File 772 bytes March 10 2021 14:36:37.
large-numbers.js File 2210 bytes March 10 2021 14:36:37.
list.js File 3152 bytes March 10 2021 14:36:37.
mkdir.js File 5178 bytes March 10 2021 14:36:37.
mode-fix.js File 277 bytes March 10 2021 14:36:37.
pack.js File 9614 bytes March 10 2021 14:36:37.
parse.js File 12140 bytes March 10 2021 14:36:37.
pax.js File 4070 bytes March 10 2021 14:36:37.
read-entry.js File 2673 bytes March 10 2021 14:36:37.
replace.js File 5492 bytes March 10 2021 14:36:37.
types.js File 1095 bytes March 10 2021 14:36:37.
unpack.js File 16856 bytes March 10 2021 14:36:37.
update.js File 852 bytes March 10 2021 14:36:37.
warn-mixin.js File 309 bytes March 10 2021 14:36:37.
winchars.js File 533 bytes March 10 2021 14:36:37.
write-entry.js File 12053 bytes March 10 2021 14:36:37.

Reading File: //usr/lib/node_modules/npm//node_modules/tar/lib//list.js

'use strict'

const Buffer = require('./buffer.js')

// XXX: This shares a lot in common with extract.js
// maybe some DRY opportunity here?

// tar -t
const hlo = require('./high-level-opt.js')
const Parser = require('./parse.js')
const fs = require('fs')
const fsm = require('fs-minipass')
const path = require('path')

const t = module.exports = (opt_, files, cb) => {
  if (typeof opt_ === 'function')
    cb = opt_, files = null, opt_ = {}
  else if (Array.isArray(opt_))
    files = opt_, opt_ = {}

  if (typeof files === 'function')
    cb = files, files = null

  if (!files)
    files = []
  else
    files = Array.from(files)

  const opt = hlo(opt_)

  if (opt.sync && typeof cb === 'function')
    throw new TypeError('callback not supported for sync tar functions')

  if (!opt.file && typeof cb === 'function')
    throw new TypeError('callback only supported with file option')

  if (files.length)
    filesFilter(opt, files)

  if (!opt.noResume)
    onentryFunction(opt)

  return opt.file && opt.sync ? listFileSync(opt)
    : opt.file ? listFile(opt, cb)
    : list(opt)
}

const onentryFunction = opt => {
  const onentry = opt.onentry
  opt.onentry = onentry ? e => {
    onentry(e)
    e.resume()
  } : e => e.resume()
}

// construct a filter that limits the file entries listed
// include child entries if a dir is included
const filesFilter = (opt, files) => {
  const map = new Map(files.map(f => [f.replace(/\/+$/, ''), true]))
  const filter = opt.filter

  const mapHas = (file, r) => {
    const root = r || path.parse(file).root || '.'
    const ret = file === root ? false
      : map.has(file) ? map.get(file)
      : mapHas(path.dirname(file), root)

    map.set(file, ret)
    return ret
  }

  opt.filter = filter
    ? (file, entry) => filter(file, entry) && mapHas(file.replace(/\/+$/, ''))
    : file => mapHas(file.replace(/\/+$/, ''))
}

const listFileSync = opt => {
  const p = list(opt)
  const file = opt.file
  let threw = true
  let fd
  try {
    const stat = fs.statSync(file)
    const readSize = opt.maxReadSize || 16*1024*1024
    if (stat.size < readSize) {
      p.end(fs.readFileSync(file))
    } else {
      let pos = 0
      const buf = Buffer.allocUnsafe(readSize)
      fd = fs.openSync(file, 'r')
      while (pos < stat.size) {
        let bytesRead = fs.readSync(fd, buf, 0, readSize, pos)
        pos += bytesRead
        p.write(buf.slice(0, bytesRead))
      }
      p.end()
    }
    threw = false
  } finally {
    if (threw && fd)
      try { fs.closeSync(fd) } catch (er) {}
  }
}

const listFile = (opt, cb) => {
  const parse = new Parser(opt)
  const readSize = opt.maxReadSize || 16*1024*1024

  const file = opt.file
  const p = new Promise((resolve, reject) => {
    parse.on('error', reject)
    parse.on('end', resolve)

    fs.stat(file, (er, stat) => {
      if (er)
        reject(er)
      else {
        const stream = new fsm.ReadStream(file, {
          readSize: readSize,
          size: stat.size
        })
        stream.on('error', reject)
        stream.pipe(parse)
      }
    })
  })
  return cb ? p.then(cb, cb) : p
}

const list = opt => new Parser(opt)

SILENT KILLER Tool