1
0
mirror of https://github.com/fuse-friends/fuse-native synced 2024-10-27 18:34:01 +00:00
This commit is contained in:
Mathias Buus 2015-08-08 22:56:37 +02:00
parent e7f5308ee5
commit f6fe161228
3 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
var fuse = require('./')
var mountPath = process.platform !== 'win32' ? './mnt' : 'M:\\';
var mountPath = process.platform !== 'win32' ? './mnt' : 'M:\\'
fuse.mount(mountPath, {
readdir: function (path, cb) {

View File

@ -672,6 +672,7 @@ static thread_fn_rtn_t bindings_thread (void *data) {
return 0;
}
#ifndef _WIN32
NAN_INLINE static Local<Date> bindings_get_date (struct timespec *out) {
int ms = (out->tv_nsec / 1000);
return NanNew<Date>(out->tv_sec * 1000 + ms);
@ -685,7 +686,7 @@ NAN_INLINE static void bindings_set_date (struct timespec *out, Local<Date> date
out->tv_sec = secs;
out->tv_nsec = ns;
}
#else
NAN_INLINE static Local<Date> bindings_get_date (time_t *out) {
return NanNew<Date>(*out * 1000.0);
}
@ -695,6 +696,7 @@ NAN_INLINE static void bindings_set_date (time_t *out, Local<Date> date) {
time_t secs = (time_t)(ms / 1000.0);
*out = secs;
}
#endif
NAN_INLINE static void bindings_set_stat (struct stat *stat, Local<Object> obj) {
if (obj->Has(NanNew<String>("dev"))) stat->st_dev = obj->Get(NanNew<String>("dev"))->NumberValue();

View File

@ -69,17 +69,18 @@ exports.mount = function (mnt, ops, cb) {
var mount = function () {
// TODO: I got a feeling this can be done better
if(os.platform() !== 'win32') {
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'))
fs.stat(path.join(mnt, '..'), function (_, parent) {
if (parent && parent.dev !== stat.dev) return cb(new Error('Mountpoint in use'))
fuse.mount(mnt, ops)
})
if (os.platform() !== 'win32') {
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'))
fs.stat(path.join(mnt, '..'), function (_, parent) {
if (parent && parent.dev !== stat.dev) return cb(new Error('Mountpoint in use'))
fuse.mount(mnt, ops)
})
})
} else {
fuse.mount(mnt, ops)
}
else fuse.mount(mnt, ops)
}
if (!ops.force) return mount()