1
0
mirror of https://github.com/fuse-friends/fuse-native synced 2024-10-27 18:34:01 +00:00

support multi mount

This commit is contained in:
Mathias Buus 2015-03-21 16:05:35 +01:00
parent f7d5e9b8ff
commit ed7d3c773f
2 changed files with 602 additions and 408 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,15 @@
var bindings = require('bindings')
var fuse = bindings('fuse_bindings')
var fs = require('fs')
var os = require('os')
var path = require('path')
var noop = function () {}
var call = function (cb) { cb() }
var MAC_FOLDER_ICON = '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericFolderIcon.icns'
var HAS_FOLDER_ICON = os.platform() === 'darwin' && fs.existsSync(MAC_FOLDER_ICON)
var FuseBuffer = function () {
this.length = 0
this.parent = undefined
@ -14,6 +18,9 @@ var FuseBuffer = function () {
FuseBuffer.prototype = Buffer.prototype
fuse.setBuffer(FuseBuffer)
fuse.setCallback(function (index, callback) {
return callback.bind(null, index)
})
exports.mount = function (mnt, ops, cb) {
if (!cb) cb = noop
@ -22,11 +29,17 @@ exports.mount = function (mnt, ops, cb) {
if (/\*|(^,)fuse-bindings(,$)/.test(process.env.DEBUG)) ops.options = ['debug'].concat(ops.options || [])
mnt = path.resolve(mnt)
if (ops.displayFolder) {
if (!ops.options) ops.options = []
ops.options.push('volname=' + path.basename(mnt))
if (HAS_FOLDER_ICON) ops.options.push('volicon=' + MAC_FOLDER_ICON)
}
var callback = function (err) {
callback = noop
ops.init = init
ops.error = error
process.nextTick(cb.bind(null, err))
setImmediate(cb.bind(null, err))
}
var init = ops.init || call