diff --git a/binding.gyp b/binding.gyp index fb7c1c1..f1bba59 100644 --- a/binding.gyp +++ b/binding.gyp @@ -6,6 +6,7 @@ "src/Main.cpp", "src/DiffWorkerCallback.cpp", "src/PatchWorkerCallback.cpp", + "src/Util.cpp", "src/c/bsdiff/bsdiff.c", "src/c/bspatch/bspatch.c", "src/c/bzip2/bzlib.c", diff --git a/src/Main.cpp b/src/Main.cpp index d172a8c..0eb520c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -22,21 +22,21 @@ namespace bsdpNode { Nan::Callback *callback = new Nan::Callback(args[3].As()); Nan::Utf8String param0(args[0]); -#ifdef WIN32 +#ifdef _WIN32 std::string oldfile = Utf8ToAnsi(*param0); #else std::string oldfile = std::string(*param0); #endif Nan::Utf8String param1(args[1]); -#ifdef WIN32 +#ifdef _WIN32 std::string newfile = Utf8ToAnsi(*param1); #else std::string newfile = std::string(*param1); #endif Nan::Utf8String param2(args[2]); -#ifdef WIN32 +#ifdef _WIN32 std::string patchfile = Utf8ToAnsi(*param2); #else std::string patchfile = std::string(*param2); @@ -65,7 +65,7 @@ std::string patchfile = std::string(*param2); char error[1024]; memset(error, 0, sizeof error); -#ifdef WIN32 +#ifdef _WIN32 int ret = bsdiff(error, Utf8ToAnsi(*oldfile).c_str(), Utf8ToAnsi(*newfile).c_str(), Utf8ToAnsi(*patchfile).c_str(), nullptr, nullptr); #else int ret = bsdiff(error, *oldfile, *newfile, *patchfile, nullptr, nullptr); @@ -86,21 +86,21 @@ std::string patchfile = std::string(*param2); Nan::Callback *callback = new Nan::Callback(args[3].As()); Nan::Utf8String param0(args[0]); -#ifdef WIN32 +#ifdef _WIN32 std::string oldfile = Utf8ToAnsi(*param0); #else std::string oldfile = std::string(*param0); #endif Nan::Utf8String param1(args[1]); -#ifdef WIN32 +#ifdef _WIN32 std::string newfile = Utf8ToAnsi(*param1); #else std::string newfile = std::string(*param1); #endif Nan::Utf8String param2(args[2]); -#ifdef WIN32 +#ifdef _WIN32 std::string patchfile = Utf8ToAnsi(*param2); #else std::string patchfile = std::string(*param2); @@ -128,7 +128,7 @@ std::string patchfile = std::string(*param2); char error[1024]; memset(error, 0, sizeof error); -#ifdef WIN32 +#ifdef _WIN32 int ret = bspatch(error, Utf8ToAnsi(*oldfile).c_str(), Utf8ToAnsi(*newfile).c_str(), Utf8ToAnsi(*patchfile).c_str(), nullptr, nullptr); #else int ret = bspatch(error, *oldfile, *newfile, *patchfile, nullptr, nullptr); diff --git a/src/Util.cpp b/src/Util.cpp index f981055..78cfb49 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,9 +1,11 @@ #include "Util.hpp" +#ifdef _WIN32 #include +#endif namespace bsdpNode { -#ifdef WIN32 +#ifdef _WIN32 std::string Utf8ToAnsi(const std::string& utf8str) { int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, utf8str.c_str(), strlen(utf8str.c_str()), NULL, 0); diff --git a/src/Util.hpp b/src/Util.hpp index ebdee65..074c354 100644 --- a/src/Util.hpp +++ b/src/Util.hpp @@ -1,12 +1,12 @@ -#ifndef Uitl_H -#define Uitl_H +#ifndef Util_H +#define Util_H #include namespace bsdpNode { -#ifdef WIN32 +#ifdef _WIN32 std::string Utf8ToAnsi(const std::string& utf8str); #endif } -#endif // Uitl_H \ No newline at end of file +#endif // Util_H \ No newline at end of file