Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-fs

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-fs - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

558

chrome.js

@@ -64,3 +64,3 @@ var util = require('util')

backtrace.stack = err.name + ': ' + err.message +
backtrace.stack.substr(backtrace.name.length)
backtrace.stack.substr(backtrace.name.length)
err = backtrace

@@ -157,15 +157,15 @@ throw err

window.requestFileSystem(window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
cfs.root.getFile(path, {},
function (fileEntry) {
setTimeout(callback, 0, true)
}, function () {
cfs.root.getDirectory(path, {},
function (dirEntry) {
setTimeout(callback, 0, true)
}, function () {
callback(false)
})
})
}, function () { setTimeout(callback, 0, false) })
function (cfs) {
cfs.root.getFile(path, {},
function (fileEntry) {
setTimeout(callback, 0, true)
}, function () {
cfs.root.getDirectory(path, {},
function (dirEntry) {
setTimeout(callback, 0, true)
}, function () {
callback(false)
})
})
}, function () { setTimeout(callback, 0, false) })
}

@@ -191,5 +191,5 @@

cfs.root.getDirectory(path, {create: true},
function (dirEntry) {
callback()
}, callback)
function (dirEntry) {
setTimeout(callback, 0)
}, callback)
}, callback)

@@ -219,28 +219,28 @@ } else {

window.requestFileSystem(window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
cfs.root.getDirectory(path, {},
function (dirEntry) {
dirEntry.remove(function () {
callback()
}, function (err) {
if (err.name === 'NotFoundError') {
var entryerr = new Error()
entryerr.code = 'ENOENT'
entryerr.path = path
callback(entryerr)
} else {
callback(err)
}
})
}, function (err) {
if (err.name === 'NotFoundError') {
var entryerr = new Error()
entryerr.code = 'ENOENT'
entryerr.path = path
callback(entryerr)
} else {
callback(err)
}
})
}, callback)
function (cfs) {
cfs.root.getDirectory(path, {},
function (dirEntry) {
dirEntry.remove(function () {
callback()
}, function (err) {
if (err.name === 'NotFoundError') {
var entryerr = new Error()
entryerr.code = 'ENOENT'
entryerr.path = path
callback(entryerr)
} else {
callback(err)
}
})
}, function (err) {
if (err.name === 'NotFoundError') {
var entryerr = new Error()
entryerr.code = 'ENOENT'
entryerr.path = path
callback(entryerr)
} else {
callback(err)
}
})
}, callback)
}

@@ -251,14 +251,22 @@

window.requestFileSystem(window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
cfs.root.getDirectory(path, {}, function (dirEntry) {
var dirReader = dirEntry.createReader()
dirReader.readEntries(function (entries) {
var fullPathList = []
for (var i = 0; i < entries.length; i++) {
fullPathList.push(entries[i].name)
}
callback(null, fullPathList)
}, callback)
function (cfs) {
cfs.root.getDirectory(path, {}, function (dirEntry) {
var dirReader = dirEntry.createReader()
dirReader.readEntries(function (entries) {
var fullPathList = []
for (var i = 0; i < entries.length; i++) {
fullPathList.push(entries[i].name)
}
callback(null, fullPathList)
}, callback)
}, callback)
}, function (err) {
if (err.name === 'NotFoundError') {
var enoent = new Error()
enoent.code = 'ENOENT'
callback(enoent)
} else {
callback(err)
}
})
}, callback)
}

@@ -276,24 +284,48 @@

}
// Some shennanigans here as folks rename and move
// at the same time :/
// First we strip the prefixed /
oldPath = resolve(oldPath)
newPath = resolve(newPath)
// Then we split the new location to get the name and the too directory
var tmpPath = newPath.split('/')
var newFileName = tmpPath.pop()
var newName = tmpPath.pop()
// if the directory happens to be root then we need to supply
// a / because gooogle devs
var toDirectory = tmpPath.join('/')
if (toDirectory === '') {
toDirectory = '/'
}
// Leaving us with oldPath the toDirectory and newName
window.requestFileSystem(
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
cfs.root.getFile(oldPath, {},
function (fileEntry) {
fileEntry.onerror = callback
cfs.root.getDirectory(toDirectory, {}, function (dirEntry) {
fileEntry.moveTo(dirEntry, newFileName)
callback()
}, callback)
fileEntry.moveTo(toDirectory, newFileName, callback)
}, callback)
}, callback)
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
// If root is / then we need a pointer to the root dir?
// Think this needs a couple of sun dir tests
if (toDirectory === '') {
toDirectory = cfs.root
}
cfs.root.getFile(oldPath, {},
function (fileEntry) {
fileEntry.onerror = callback
cfs.root.getDirectory(toDirectory, {}, function (dirEntry) {
fileEntry.moveTo(dirEntry, newName)
callback()
}, callback)
fileEntry.moveTo(toDirectory, newName, callback)
}, function (err) {
// we need to move the directory instead
if (err.name === 'TypeMismatchError') {
cfs.root.getDirectory('/' + oldPath, {}, function (dirEntry) {
dirEntry.moveTo(toDirectory, newName, function () {
callback()
}, function (err) {
callback(err)
})
})
} else {
callback(err)
}
})
}, callback)
}

@@ -336,57 +368,57 @@

window.requestFileSystem(
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
var opts = {}
cfs.root.getFile(path, opts, function (fileEntry) {
fileEntry.file(function (file) {
var statval = { dev: 0,
mode: '0777',
nlink: 0,
uid: 0,
gid: 0,
rdev: 0,
ino: 0,
size: file.size,
atime: null,
mtime: file.lastModifiedDate,
ctime: null }
statval.isDirectory = function () { return false }
statval.isFile = function () { return true }
statval.isSocket = function () { return false }
statval.isBlockDevice = function () { return false }
statval.isCharacterDevice = function () { return false }
statval.isFIFO = function () { return false }
statval.isSymbolicLink = function () { return false }
callback(null, statval)
})
}, function (err) {
if (err.name === 'TypeMismatchError') {
cfs.root.getDirectory(path, opts, function (dirEntry) {
var statval = { dev: 0,
mode: '0777',
nlink: 0,
uid: 0,
gid: 0,
rdev: 0,
ino: 0,
size: 0,
atime: null,
mtime: new Date(0),
ctime: null,
blksize: -1,
blocks: -1 }
statval.isDirectory = function () { return true }
statval.isFile = function () { return false }
statval.isSocket = function () { return false }
statval.isBlockDevice = function () { return false }
statval.isCharacterDevice = function () { return false }
statval.isFIFO = function () { return false }
statval.isSymbolicLink = function () { return false }
callback(null, statval)
})
} else {
callback(err)
}
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
var opts = {}
cfs.root.getFile(path, opts, function (fileEntry) {
fileEntry.file(function (file) {
var statval = { dev: 0,
mode: '0777',
nlink: 0,
uid: 0,
gid: 0,
rdev: 0,
ino: 0,
size: file.size,
atime: null,
mtime: file.lastModifiedDate,
ctime: null }
statval.isDirectory = function () { return false }
statval.isFile = function () { return true }
statval.isSocket = function () { return false }
statval.isBlockDevice = function () { return false }
statval.isCharacterDevice = function () { return false }
statval.isFIFO = function () { return false }
statval.isSymbolicLink = function () { return false }
callback(null, statval)
})
}, function (err) {
if (err.name === 'TypeMismatchError') {
cfs.root.getDirectory(path, opts, function (dirEntry) {
var statval = { dev: 0,
mode: '0777',
nlink: 0,
uid: 0,
gid: 0,
rdev: 0,
ino: 0,
size: 0,
atime: null,
mtime: new Date(0),
ctime: null,
blksize: -1,
blocks: -1 }
statval.isDirectory = function () { return true }
statval.isFile = function () { return false }
statval.isSocket = function () { return false }
statval.isBlockDevice = function () { return false }
statval.isCharacterDevice = function () { return false }
statval.isFIFO = function () { return false }
statval.isSymbolicLink = function () { return false }
callback(null, statval)
})
}, callback)
} else {
callback(err)
}
})
}, callback)
}

@@ -406,60 +438,60 @@

window.requestFileSystem(
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
var opts = {}
if (flags.indexOf('w') > -1) {
opts = {create: true}
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
var opts = {}
if (flags.indexOf('w') > -1) {
opts = {create: true}
}
if (flags.indexOf('x') > -1) {
opts.exclusive = true
}
cfs.root.getFile(
path,
opts,
function (fileEntry) {
// if its a write then we get the file writer
// otherwise we get the file because 'standards'
if (flags.indexOf('w') > -1 || flags.indexOf('a') > -1) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.fullPath = fileEntry.fullPath
fds[fileWriter.fullPath] = {}
fds[fileWriter.fullPath].status = 'open'
fileWriter.key = fileWriter.fullPath
callback(null, fileWriter)
}, callback)
} else {
fileEntry.file(function (file) {
fds[file.fullPath] = {}
fds[file.fullPath].status = 'open'
file.key = file.fullPath
callback(null, file)
})
}
if (flags.indexOf('x') > -1) {
opts.exclusive = true
}, function (err) {
if (err.name === 'NotFoundError') {
var enoent = new Error()
enoent.code = 'ENOENT'
callback(enoent)
} else if (err.name === 'TypeMismatchError' || err.name === 'SecurityError') {
// Work around for directory file descriptor
// It's a write on a directory
if (flags.indexOf('w') > -1) {
var eisdir = new Error()
eisdir.code = 'EISDIR'
callback(eisdir)
} else {
var dird = {}
dird.filePath = path
callback(null, dird)
}
} else if (err.name === 'InvalidModificationError') {
var eexists = new Error()
eexists.code = 'EEXIST'
callback(eexists)
} else {
callback(err)
}
cfs.root.getFile(
path,
opts,
function (fileEntry) {
// if its a write then we get the file writer
// otherwise we get the file because 'standards'
if (flags.indexOf('w') > -1 || flags.indexOf('a') > -1) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.fullPath = fileEntry.fullPath
fds[fileWriter.fullPath] = {}
fds[fileWriter.fullPath].status = 'open'
fileWriter.key = fileWriter.fullPath
callback(null, fileWriter)
}, callback)
} else {
fileEntry.file(function (file) {
fds[file.fullPath] = {}
fds[file.fullPath].status = 'open'
file.key = file.fullPath
callback(null, file)
})
}
}, function (err) {
if (err.name === 'NotFoundError') {
var enoent = new Error()
enoent.code = 'ENOENT'
callback(enoent)
} else if (err.name === 'TypeMismatchError' || err.name === 'SecurityError') {
// Work around for directory file descriptor
// It's a write on a directory
if (flags.indexOf('w') > -1) {
var eisdir = new Error()
eisdir.code = 'EISDIR'
callback(eisdir)
} else {
var dird = {}
dird.filePath = path
callback(null, dird)
}
} else if (err.name === 'InvalidModificationError') {
var eexists = new Error()
eexists.code = 'EEXIST'
callback(eexists)
} else {
callback(err)
}
})
}, callback)
})
}, callback)
}

@@ -538,4 +570,3 @@

// no-op the onprogressevent
fileReader.onprogress = function () {
}
fileReader.onprogress = function () {}
if (fd.type === 'text/plain') {

@@ -562,31 +593,31 @@ fileReader.readAsText(data)

window.requestFileSystem(
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
var opts = {}
cfs.root.getFile(
path,
opts,
function (fileEntry) {
fileEntry.file(function (file) {
fileEntry.onerror = callback
var fileReader = new FileReader() // eslint-disable-line
fileReader.onload = function (evt) {
if (options.encoding === null) {
window.setTimeout(callback, 0, null, new Buffer(this.result, 'binary'))
} else {
window.setTimeout(callback, 0, null, this.result)
}
}
fileReader.onerror = function (evt) {
callback(evt, null)
}
window.PERSISTENT, FILESYSTEM_DEFAULT_SIZE,
function (cfs) {
var opts = {}
cfs.root.getFile(
path,
opts,
function (fileEntry) {
fileEntry.file(function (file) {
fileEntry.onerror = callback
var fileReader = new FileReader() // eslint-disable-line
fileReader.onload = function (evt) {
if (options.encoding === null) {
window.setTimeout(callback, 0, null, new Buffer(this.result, 'binary'))
} else {
window.setTimeout(callback, 0, null, this.result)
}
}
fileReader.onerror = function (evt) {
callback(evt, null)
}
if (file.type === 'text/plain') {
fileReader.readAsText(file)
} else if (file.type === 'application/octet-binary') {
fileReader.readAsArrayBuffer(file)
}
})
}, callback)
}, callback)
if (file.type === 'text/plain') {
fileReader.readAsText(file)
} else if (file.type === 'application/octet-binary') {
fileReader.readAsArrayBuffer(file)
}
})
}, callback)
}, callback)
}

@@ -668,7 +699,7 @@

cfs.root.getFile(
path,
{},
function (fileEntry) {
fileEntry.remove(callback)
})
path,
{},
function (fileEntry) {
fileEntry.remove(callback)
})
}, callback)

@@ -706,29 +737,29 @@ } else {

cfs.root.getFile(
path,
opts,
function (fileEntry) {
// if its a write then we get the file writer
// otherwise we get the file because 'standards'
if (flag === 'w') {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onerror = callback
if (typeof callback === 'function') {
fileWriter.onwriteend = function (evt) {
window.setTimeout(callback, 0, null, evt)
}
} else {
fileWriter.onwriteend = function () {}
}
fileWriter.onprogress = function () {}
var blob = new Blob([data], {type: 'text/plain'}) // eslint-disable-line
fileWriter.write(blob)
}, function (evt) {
if (evt.type !== 'writeend') {
callback(evt)
}
})
path,
opts,
function (fileEntry) {
// if its a write then we get the file writer
// otherwise we get the file because 'standards'
if (flag === 'w') {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onerror = callback
if (typeof callback === 'function') {
fileWriter.onwriteend = function (evt) {
window.setTimeout(callback, 0, null, evt)
}
} else {
callback('incorrect flag')
fileWriter.onwriteend = function () {}
}
}, function () {})
fileWriter.onprogress = function () {}
var blob = new Blob([data], {type: 'text/plain'}) // eslint-disable-line
fileWriter.write(blob)
}, function (evt) {
if (evt.type !== 'writeend') {
callback(evt)
}
})
} else {
callback('incorrect flag')
}
}, function () {})
}, callback)

@@ -758,26 +789,26 @@ }

cfs.root.getFile(
path,
opts,
function (fileEntry) {
// if its a write then we get the file writer
// otherwise we get the file because 'standards'
if (flag === 'a') {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onerror = callback
if (typeof callback === 'function') {
fileWriter.onwriteend = function (evt) {
window.setTimeout(callback, 0, null, evt)
}
} else {
fileWriter.onwriteend = function () {}
}
fileWriter.onprogress = function () {}
fileWriter.seek(fileWriter.length)
var blob = new Blob([data], {type: 'text/plain'}) // eslint-disable-line
fileWriter.write(blob)
}, callback)
path,
opts,
function (fileEntry) {
// if its a write then we get the file writer
// otherwise we get the file because 'standards'
if (flag === 'a') {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onerror = callback
if (typeof callback === 'function') {
fileWriter.onwriteend = function (evt) {
window.setTimeout(callback, 0, null, evt)
}
} else {
callback('incorrect flag')
fileWriter.onwriteend = function () {}
}
fileWriter.onprogress = function () {}
fileWriter.seek(fileWriter.length)
var blob = new Blob([data], {type: 'text/plain'}) // eslint-disable-line
fileWriter.write(blob)
}, callback)
} else {
callback('incorrect flag')
}
}, callback)
}, callback)

@@ -798,3 +829,2 @@ }

exports.close = function (fd, callback) {
delete fds[fd.fullPath]

@@ -837,3 +867,3 @@ var cb = makeCallback(callback)

this.autoClose = options.hasOwnProperty('autoClose') ?
options.autoClose : true
options.autoClose : true
this.pos = undefined

@@ -939,3 +969,3 @@

exports.read(this.fd, new Buffer(this.fd.size), this.start, this.end, 0, onread)
// this.once('finish', this.close)
// this.once('finish', this.close)
}

@@ -942,0 +972,0 @@

{
"name": "chrome-fs",
"version": "5.0.0",
"version": "6.0.0",
"description": "Use the Node `fs` API in Chrome Apps",

@@ -5,0 +5,0 @@ "main": "main.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc