mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
Expose beforeMount, afterMount, configure, unconfigure + updated bindings.gyp
This commit is contained in:
parent
b2d71c8a29
commit
d76d36d087
86
binding.gyp
86
binding.gyp
@ -1,67 +1,25 @@
|
||||
{
|
||||
"targets": [{
|
||||
"target_name": "fuse_bindings",
|
||||
"sources": ["fuse-bindings.cc", "abstractions.cc"],
|
||||
"include_dirs": [
|
||||
"<!(node -e \"require('nan')\")"
|
||||
],
|
||||
"conditions": [
|
||||
['OS!="win"', {
|
||||
'variables':
|
||||
{
|
||||
'fuse__include_dirs%': '<!(pkg-config fuse --cflags-only-I | sed s/-I//g)',
|
||||
'fuse__library_dirs%': '',
|
||||
'fuse__libraries%': '<!(pkg-config --libs-only-L --libs-only-l fuse)'
|
||||
},
|
||||
"include_dirs": [
|
||||
"<@(fuse__include_dirs)"
|
||||
],
|
||||
'library_dirs': [
|
||||
'<@(fuse__library_dirs)',
|
||||
],
|
||||
"link_settings": {
|
||||
"libraries": [
|
||||
"<@(fuse__libraries)"
|
||||
]
|
||||
}
|
||||
}],
|
||||
['OS=="win"', {
|
||||
"variables": {
|
||||
'dokan__install_dir%': '$(DokanLibrary1)/include/fuse'
|
||||
},
|
||||
"include_dirs": [
|
||||
"<(dokan__install_dir)",
|
||||
"$(INCLUDE)"
|
||||
],
|
||||
"link_settings": {
|
||||
"libraries": [
|
||||
"<(dokan__library)"
|
||||
]
|
||||
},
|
||||
"conditions": [
|
||||
['target_arch=="x64"', {
|
||||
"variables": { 'dokan__library%': '$(DokanLibrary1_LibraryPath_x64)/dokanfuse1' }
|
||||
}, {
|
||||
"variables": { 'dokan__library%': '$(DokanLibrary1_LibraryPath_x86)/dokanfuse1' }
|
||||
}]
|
||||
]
|
||||
}]
|
||||
],
|
||||
"configurations": {
|
||||
"Debug": {
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"RuntimeLibrary": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
"Release": {
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"RuntimeLibrary": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"targets": [{
|
||||
"target_name": "fuse",
|
||||
"include_dirs": [
|
||||
"<!(node -e \"require('napi-macros')\")",
|
||||
"<!(node -e \"require('nan')\")",
|
||||
"<!(node -e \"require('fuse-shared-library/include')\")",
|
||||
],
|
||||
"libraries": [
|
||||
"<!(node -e \"require('fuse-shared-library/lib')\")",
|
||||
],
|
||||
"sources": [
|
||||
"fuse-bindings.cc",
|
||||
"abstractions.cc"
|
||||
]
|
||||
}, {
|
||||
"target_name": "postinstall",
|
||||
"type": "none",
|
||||
"dependencies": ["fuse"],
|
||||
"copies": [{
|
||||
"destination": "build/Release",
|
||||
"files": [ "<!(node -e \"require('fuse-shared-library/lib')\")" ],
|
||||
}]
|
||||
}]
|
||||
}
|
||||
|
30
index.js
30
index.js
@ -1,9 +1,11 @@
|
||||
var fuse = require('node-gyp-build')(__dirname)
|
||||
var fs = require('fs')
|
||||
var os = require('os')
|
||||
var xtend = require('xtend')
|
||||
var path = require('path')
|
||||
|
||||
var fuse = require('node-gyp-build')(__dirname)
|
||||
var { beforeMount, beforeUnmount, configure, unconfigure } = require('fuse-shared-library')
|
||||
|
||||
var noop = function () {}
|
||||
var call = function (cb) { cb() }
|
||||
|
||||
@ -69,8 +71,12 @@ exports.mount = function (mnt, ops, opts, cb) {
|
||||
}
|
||||
|
||||
var mount = function () {
|
||||
// TODO: I got a feeling this can be done better
|
||||
if (os.platform() !== 'win32') {
|
||||
if (beforeMount) beforeMount(domount)
|
||||
else domount(null)
|
||||
|
||||
function domount (err) {
|
||||
if (err) return cb(err)
|
||||
// TODO: I got a feeling this can be done better
|
||||
fs.stat(mnt, function (err, stat) {
|
||||
if (err) return cb(new Error('Mountpoint does not exist'))
|
||||
if (!stat.isDirectory()) return cb(new Error('Mountpoint is not a directory'))
|
||||
@ -79,8 +85,6 @@ exports.mount = function (mnt, ops, opts, cb) {
|
||||
fuse.mount(mnt, ops)
|
||||
})
|
||||
})
|
||||
} else {
|
||||
fuse.mount(mnt, ops)
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +93,21 @@ exports.mount = function (mnt, ops, opts, cb) {
|
||||
}
|
||||
|
||||
exports.unmount = function (mnt, cb) {
|
||||
fuse.unmount(path.resolve(mnt), cb)
|
||||
if (beforeUnmount) beforeUnmount(unmount)
|
||||
else unmount(null)
|
||||
|
||||
function unmount (err) {
|
||||
if (err) return cb(err)
|
||||
fuse.unmount(path.resolve(mnt), cb)
|
||||
}
|
||||
}
|
||||
|
||||
exports.configure = function (cb) {
|
||||
return configure(cb)
|
||||
}
|
||||
|
||||
exports.unconfigure = function (cb) {
|
||||
return unconfigure(cb)
|
||||
}
|
||||
|
||||
exports.errno = function (code) {
|
||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fuse-bindings",
|
||||
"version": "2.11.2",
|
||||
"name": "fuse-native",
|
||||
"version": "1.0.0",
|
||||
"description": "Fully maintained fuse bindings for Node that aims to cover the entire FUSE api",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@ -11,7 +11,9 @@
|
||||
},
|
||||
"gypfile": true,
|
||||
"dependencies": {
|
||||
"nan": "^2.3.5",
|
||||
"fuse-shared-library": "^1.0.1",
|
||||
"nan": "^2.13.2",
|
||||
"napi-macros": "^1.8.2",
|
||||
"node-gyp-build": "^3.2.2",
|
||||
"xtend": "^4.0.1"
|
||||
},
|
||||
@ -23,12 +25,12 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mafintosh/fuse-bindings.git"
|
||||
"url": "https://github.com/fuse-friends/fuse-native.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/fuse-bindings/issues"
|
||||
"url": "https://github.com/fuse-friends/fuse-native/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/fuse-bindings"
|
||||
"homepage": "https://github.com/fuse-friends/fuse-native"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user