1
0
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:
Andrew Osheroff 2019-04-12 14:00:22 +02:00
parent b2d71c8a29
commit d76d36d087
3 changed files with 54 additions and 76 deletions

View File

@ -1,67 +1,25 @@
{ {
"targets": [{ "targets": [{
"target_name": "fuse_bindings", "target_name": "fuse",
"sources": ["fuse-bindings.cc", "abstractions.cc"], "include_dirs": [
"include_dirs": [ "<!(node -e \"require('napi-macros')\")",
"<!(node -e \"require('nan')\")" "<!(node -e \"require('nan')\")",
], "<!(node -e \"require('fuse-shared-library/include')\")",
"conditions": [ ],
['OS!="win"', { "libraries": [
'variables': "<!(node -e \"require('fuse-shared-library/lib')\")",
{ ],
'fuse__include_dirs%': '<!(pkg-config fuse --cflags-only-I | sed s/-I//g)', "sources": [
'fuse__library_dirs%': '', "fuse-bindings.cc",
'fuse__libraries%': '<!(pkg-config --libs-only-L --libs-only-l fuse)' "abstractions.cc"
}, ]
"include_dirs": [ }, {
"<@(fuse__include_dirs)" "target_name": "postinstall",
], "type": "none",
'library_dirs': [ "dependencies": ["fuse"],
'<@(fuse__library_dirs)', "copies": [{
], "destination": "build/Release",
"link_settings": { "files": [ "<!(node -e \"require('fuse-shared-library/lib')\")" ],
"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
}
}
}
}
}] }]
}]
} }

View File

@ -1,9 +1,11 @@
var fuse = require('node-gyp-build')(__dirname)
var fs = require('fs') var fs = require('fs')
var os = require('os') var os = require('os')
var xtend = require('xtend') var xtend = require('xtend')
var path = require('path') var path = require('path')
var fuse = require('node-gyp-build')(__dirname)
var { beforeMount, beforeUnmount, configure, unconfigure } = require('fuse-shared-library')
var noop = function () {} var noop = function () {}
var call = function (cb) { cb() } var call = function (cb) { cb() }
@ -69,8 +71,12 @@ exports.mount = function (mnt, ops, opts, cb) {
} }
var mount = function () { var mount = function () {
// TODO: I got a feeling this can be done better if (beforeMount) beforeMount(domount)
if (os.platform() !== 'win32') { 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) { fs.stat(mnt, function (err, stat) {
if (err) return cb(new Error('Mountpoint does not exist')) if (err) return cb(new Error('Mountpoint does not exist'))
if (!stat.isDirectory()) return cb(new Error('Mountpoint is not a directory')) 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) 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) { 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) { exports.errno = function (code) {

View File

@ -1,6 +1,6 @@
{ {
"name": "fuse-bindings", "name": "fuse-native",
"version": "2.11.2", "version": "1.0.0",
"description": "Fully maintained fuse bindings for Node that aims to cover the entire FUSE api", "description": "Fully maintained fuse bindings for Node that aims to cover the entire FUSE api",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -11,7 +11,9 @@
}, },
"gypfile": true, "gypfile": true,
"dependencies": { "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", "node-gyp-build": "^3.2.2",
"xtend": "^4.0.1" "xtend": "^4.0.1"
}, },
@ -23,12 +25,12 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/mafintosh/fuse-bindings.git" "url": "https://github.com/fuse-friends/fuse-native.git"
}, },
"author": "Mathias Buus (@mafintosh)", "author": "Mathias Buus (@mafintosh)",
"license": "MIT", "license": "MIT",
"bugs": { "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"
} }