"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/install/writable.js" (7 Feb 2017, 1027 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 'use strict'
    2 var path = require('path')
    3 var fs = require('fs')
    4 var inflight = require('inflight')
    5 var accessError = require('./access-error.js')
    6 var andIgnoreErrors = require('./and-ignore-errors.js')
    7 var isFsAccessAvailable = require('./is-fs-access-available.js')
    8 
    9 if (isFsAccessAvailable) {
   10   module.exports = fsAccessImplementation
   11 } else {
   12   module.exports = fsOpenImplementation
   13 }
   14 
   15 // exposed only for testing purposes
   16 module.exports.fsAccessImplementation = fsAccessImplementation
   17 module.exports.fsOpenImplementation = fsOpenImplementation
   18 
   19 function fsAccessImplementation (dir, done) {
   20   done = inflight('writable:' + dir, done)
   21   if (!done) return
   22   fs.access(dir, fs.W_OK, done)
   23 }
   24 
   25 function fsOpenImplementation (dir, done) {
   26   done = inflight('writable:' + dir, done)
   27   if (!done) return
   28   var tmp = path.join(dir, '.npm.check.permissions')
   29   fs.open(tmp, 'w', function (er, fd) {
   30     if (er) return done(accessError(dir, er))
   31     fs.close(fd, function () {
   32       fs.unlink(tmp, andIgnoreErrors(done))
   33     })
   34   })
   35 }