From 056542d9ad1aa2b3e1b7f8b4953a9ab6fafc0312 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Fri, 13 Mar 2015 19:05:41 +0100 Subject: [PATCH] fix utf-8 strings --- fuse-bindings.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/fuse-bindings.cc b/fuse-bindings.cc index 590b358..f5f3d3c 100644 --- a/fuse-bindings.cc +++ b/fuse-bindings.cc @@ -521,7 +521,8 @@ static void bindings_set_statfs (Local obj, struct statvfs *statfs) { // static void bindings_set_dirs (Local dirs) { for (uint32_t i = 0; i < dirs->Length(); i++) { - if (bindings.filler(bindings.data, (char *) *NanUtf8String(dirs->Get(i).As()), &empty_stat, 0)) break; + NanUtf8String dir(dirs->Get(i)); + if (bindings.filler(bindings.data, *dir, &empty_stat, 0)) break; } } @@ -913,7 +914,8 @@ NAN_METHOD(Mount) { NanScope(); memset(&empty_stat, 0, sizeof(empty_stat)); // zero empty stat - char *path = (char *) *NanUtf8String(args[0].As()); + + NanUtf8String path(args[0]); Local ops = args[1].As(); bindings.ops_init = ops->Has(NanNew("init")) ? new NanCallback(ops->Get(NanNew("init")).As()) : NULL; @@ -951,12 +953,15 @@ NAN_METHOD(Mount) { NanAssignPersistent(bindings.buffer_persistent, args[2].As()); bindings.callback = new NanCallback(NanNew(OpCallback)->GetFunction()); - stpcpy(bindings.mnt, path); + stpcpy(bindings.mnt, *path); stpcpy(bindings.mntopts, "-o"); Local options = ops->Get(NanNew("options")).As(); if (options->IsArray()) { - for (uint32_t i = 0; i < options->Length(); i++) bindings_append_opt((char *) *NanUtf8String(options->Get(i).As())); + for (uint32_t i = 0; i < options->Length(); i++) { + NanUtf8String option(options->Get(i)); + bindings_append_opt(*option); + } } // yolo @@ -972,8 +977,8 @@ NAN_METHOD(Mount) { NAN_METHOD(UnmountSync) { NanScope(); - char *path = (char *) *NanUtf8String(args[0].As()); - bindings_unmount(path); + NanUtf8String path(args[0]); + bindings_unmount(*path); NanReturnUndefined(); } @@ -997,14 +1002,13 @@ class UnmountWorker : public NanAsyncWorker { char *path; }; - NAN_METHOD(Unmount) { NanScope(); - char *path = (char *) *NanUtf8String(args[0].As()); + NanUtf8String path(args[0]); Local callback = args[1].As(); char *path_alloc = (char *) malloc(1024); - stpcpy(path_alloc, path); + stpcpy(path_alloc, *path); NanAsyncQueueWorker(new UnmountWorker(new NanCallback(callback), path_alloc)); NanReturnUndefined();