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:
parent
f7d5e9b8ff
commit
ed7d3c773f
995
fuse-bindings.cc
995
fuse-bindings.cc
File diff suppressed because it is too large
Load Diff
15
index.js
15
index.js
@ -1,11 +1,15 @@
|
|||||||
var bindings = require('bindings')
|
var bindings = require('bindings')
|
||||||
var fuse = bindings('fuse_bindings')
|
var fuse = bindings('fuse_bindings')
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
|
var os = require('os')
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
|
|
||||||
var noop = function () {}
|
var noop = function () {}
|
||||||
var call = function (cb) { cb() }
|
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 () {
|
var FuseBuffer = function () {
|
||||||
this.length = 0
|
this.length = 0
|
||||||
this.parent = undefined
|
this.parent = undefined
|
||||||
@ -14,6 +18,9 @@ var FuseBuffer = function () {
|
|||||||
FuseBuffer.prototype = Buffer.prototype
|
FuseBuffer.prototype = Buffer.prototype
|
||||||
|
|
||||||
fuse.setBuffer(FuseBuffer)
|
fuse.setBuffer(FuseBuffer)
|
||||||
|
fuse.setCallback(function (index, callback) {
|
||||||
|
return callback.bind(null, index)
|
||||||
|
})
|
||||||
|
|
||||||
exports.mount = function (mnt, ops, cb) {
|
exports.mount = function (mnt, ops, cb) {
|
||||||
if (!cb) cb = noop
|
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 || [])
|
if (/\*|(^,)fuse-bindings(,$)/.test(process.env.DEBUG)) ops.options = ['debug'].concat(ops.options || [])
|
||||||
mnt = path.resolve(mnt)
|
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) {
|
var callback = function (err) {
|
||||||
callback = noop
|
callback = noop
|
||||||
ops.init = init
|
ops.init = init
|
||||||
ops.error = error
|
ops.error = error
|
||||||
process.nextTick(cb.bind(null, err))
|
setImmediate(cb.bind(null, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
var init = ops.init || call
|
var init = ops.init || call
|
||||||
|
Loading…
Reference in New Issue
Block a user