mirror of
https://github.com/fuse-friends/fuse-native
synced 2025-06-13 12:53:54 +00:00
clean up #7
This commit is contained in:
parent
e7f5308ee5
commit
f6fe161228
@ -1,6 +1,6 @@
|
|||||||
var fuse = require('./')
|
var fuse = require('./')
|
||||||
|
|
||||||
var mountPath = process.platform !== 'win32' ? './mnt' : 'M:\\';
|
var mountPath = process.platform !== 'win32' ? './mnt' : 'M:\\'
|
||||||
|
|
||||||
fuse.mount(mountPath, {
|
fuse.mount(mountPath, {
|
||||||
readdir: function (path, cb) {
|
readdir: function (path, cb) {
|
||||||
|
@ -672,6 +672,7 @@ static thread_fn_rtn_t bindings_thread (void *data) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
NAN_INLINE static Local<Date> bindings_get_date (struct timespec *out) {
|
NAN_INLINE static Local<Date> bindings_get_date (struct timespec *out) {
|
||||||
int ms = (out->tv_nsec / 1000);
|
int ms = (out->tv_nsec / 1000);
|
||||||
return NanNew<Date>(out->tv_sec * 1000 + ms);
|
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_sec = secs;
|
||||||
out->tv_nsec = ns;
|
out->tv_nsec = ns;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
NAN_INLINE static Local<Date> bindings_get_date (time_t *out) {
|
NAN_INLINE static Local<Date> bindings_get_date (time_t *out) {
|
||||||
return NanNew<Date>(*out * 1000.0);
|
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);
|
time_t secs = (time_t)(ms / 1000.0);
|
||||||
*out = secs;
|
*out = secs;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NAN_INLINE static void bindings_set_stat (struct stat *stat, Local<Object> obj) {
|
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();
|
if (obj->Has(NanNew<String>("dev"))) stat->st_dev = obj->Get(NanNew<String>("dev"))->NumberValue();
|
||||||
|
19
index.js
19
index.js
@ -69,17 +69,18 @@ exports.mount = function (mnt, ops, cb) {
|
|||||||
|
|
||||||
var mount = function () {
|
var mount = function () {
|
||||||
// TODO: I got a feeling this can be done better
|
// TODO: I got a feeling this can be done better
|
||||||
if(os.platform() !== 'win32') {
|
if (os.platform() !== 'win32') {
|
||||||
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'))
|
||||||
fs.stat(path.join(mnt, '..'), function (_, parent) {
|
fs.stat(path.join(mnt, '..'), function (_, parent) {
|
||||||
if (parent && parent.dev !== stat.dev) return cb(new Error('Mountpoint in use'))
|
if (parent && parent.dev !== stat.dev) return cb(new Error('Mountpoint in use'))
|
||||||
fuse.mount(mnt, ops)
|
fuse.mount(mnt, ops)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fuse.mount(mnt, ops)
|
||||||
}
|
}
|
||||||
else fuse.mount(mnt, ops)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ops.force) return mount()
|
if (!ops.force) return mount()
|
||||||
|
Loading…
Reference in New Issue
Block a user