Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Fix PR #26
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetandezeiraud committed Nov 14, 2023
1 parent 918a70e commit c7c095b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ namespace bsdpNode {
Nan::Callback *callback = new Nan::Callback(args[3].As<v8::Function>());

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);
Expand Down Expand Up @@ -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);
Expand All @@ -86,21 +86,21 @@ std::string patchfile = std::string(*param2);
Nan::Callback *callback = new Nan::Callback(args[3].As<v8::Function>());

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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/Util.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "Util.hpp"

#ifdef _WIN32
#include <Windows.h>
#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);
Expand Down
8 changes: 4 additions & 4 deletions src/Util.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef Uitl_H
#define Uitl_H
#ifndef Util_H
#define Util_H

#include <string>

namespace bsdpNode {
#ifdef WIN32
#ifdef _WIN32
std::string Utf8ToAnsi(const std::string& utf8str);
#endif
}

#endif // Uitl_H
#endif // Util_H

0 comments on commit c7c095b

Please sign in to comment.