diff --git a/example.js b/example.js index 540bc99..7d5e19f 100644 --- a/example.js +++ b/example.js @@ -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) { diff --git a/fuse-bindings.cc b/fuse-bindings.cc index a437c52..b2b133a 100644 --- a/fuse-bindings.cc +++ b/fuse-bindings.cc @@ -672,6 +672,7 @@ static thread_fn_rtn_t bindings_thread (void *data) { return 0; } +#ifndef _WIN32 NAN_INLINE static Local bindings_get_date (struct timespec *out) { int ms = (out->tv_nsec / 1000); return NanNew(out->tv_sec * 1000 + ms); @@ -685,7 +686,7 @@ NAN_INLINE static void bindings_set_date (struct timespec *out, Local date out->tv_sec = secs; out->tv_nsec = ns; } - +#else NAN_INLINE static Local bindings_get_date (time_t *out) { return NanNew(*out * 1000.0); } @@ -695,6 +696,7 @@ NAN_INLINE static void bindings_set_date (time_t *out, Local date) { time_t secs = (time_t)(ms / 1000.0); *out = secs; } +#endif NAN_INLINE static void bindings_set_stat (struct stat *stat, Local obj) { if (obj->Has(NanNew("dev"))) stat->st_dev = obj->Get(NanNew("dev"))->NumberValue(); diff --git a/index.js b/index.js index c02e53e..9a070e8 100644 --- a/index.js +++ b/index.js @@ -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()