Skip to content

Commit

Permalink
src: move
Browse files Browse the repository at this point in the history
  • Loading branch information
yamachu committed Jan 24, 2025
1 parent 7edf181 commit 0041793
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
13 changes: 0 additions & 13 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3146,19 +3146,6 @@ static void GetFormatOfExtensionlessFile(
}

#ifdef _WIN32
std::wstring ConvertToWideString(const std::string& str) {
int size_needed = MultiByteToWideChar(
CP_UTF8, 0, &str[0], static_cast<int>(str.size()), nullptr, 0);
std::wstring wstrTo(size_needed, 0);
MultiByteToWideChar(CP_UTF8,
0,
&str[0],
static_cast<int>(str.size()),
&wstrTo[0],
size_needed);
return wstrTo;
}

#define BufferValueToPath(str) \
std::filesystem::path(ConvertToWideString(str.ToString()))

Expand Down
20 changes: 0 additions & 20 deletions src/node_modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

#include "simdjson.h"

#ifdef _WIN32
#include <windows.h>
#endif

namespace node {
namespace modules {

Expand Down Expand Up @@ -330,22 +326,6 @@ const BindingData::PackageConfig* BindingData::TraverseParent(
return nullptr;
}

#ifdef _WIN32
std::wstring ConvertToWideString(const std::string& str) {
auto cp = GetACP();
int size_needed = MultiByteToWideChar(
cp, 0, &str[0], static_cast<int>(str.size()), nullptr, 0);
std::wstring wstrTo(size_needed, 0);
MultiByteToWideChar(cp,
0,
&str[0],
static_cast<int>(str.size()),
&wstrTo[0],
size_needed);
return wstrTo;
}
#endif

void BindingData::GetNearestParentPackageJSON(
const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_GE(args.Length(), 1);
Expand Down
12 changes: 12 additions & 0 deletions src/util-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,18 @@ bool IsWindowsBatchFile(const char* filename) {
#endif // _WIN32
}

#ifdef _WIN32
inline std::wstring ConvertToWideString(const std::string& str) {
auto cp = GetACP();
int size_needed = MultiByteToWideChar(
cp, 0, &str[0], static_cast<int>(str.size()), nullptr, 0);
std::wstring wstrTo(size_needed, 0);
MultiByteToWideChar(
cp, 0, &str[0], static_cast<int>(str.size()), &wstrTo[0], size_needed);
return wstrTo;
}
#endif // _WIN32

} // namespace node

#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
Expand Down

0 comments on commit 0041793

Please sign in to comment.