Skip to content

Commit 70c0a70

Browse files
committed
resolving conflict
1 parent 50f5e96 commit 70c0a70

File tree

1 file changed

+37
-50
lines changed

1 file changed

+37
-50
lines changed

src/node_file.cc

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,55 +1614,6 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
16141614
}
16151615
}
16161616

1617-
#ifdef _WIN32
1618-
std::wstring ConvertToWideString(const std::string& str) {
1619-
int size_needed = MultiByteToWideChar(
1620-
CP_UTF8, 0, &str[0], static_cast<int>(str.size()), nullptr, 0);
1621-
std::wstring wstrTo(size_needed, 0);
1622-
MultiByteToWideChar(CP_UTF8,
1623-
0,
1624-
&str[0],
1625-
static_cast<int>(str.size()),
1626-
&wstrTo[0],
1627-
size_needed);
1628-
return wstrTo;
1629-
}
1630-
1631-
#define BufferValueToPath(str) \
1632-
std::filesystem::path(ConvertToWideString(str.ToString()))
1633-
1634-
std::string ConvertWideToUTF8(const std::wstring& wstr) {
1635-
if (wstr.empty()) return std::string();
1636-
1637-
int size_needed = WideCharToMultiByte(CP_UTF8,
1638-
0,
1639-
&wstr[0],
1640-
static_cast<int>(wstr.size()),
1641-
nullptr,
1642-
0,
1643-
nullptr,
1644-
nullptr);
1645-
std::string strTo(size_needed, 0);
1646-
WideCharToMultiByte(CP_UTF8,
1647-
0,
1648-
&wstr[0],
1649-
static_cast<int>(wstr.size()),
1650-
&strTo[0],
1651-
size_needed,
1652-
nullptr,
1653-
nullptr);
1654-
return strTo;
1655-
}
1656-
1657-
#define PathToString(path) ConvertWideToUTF8(path.wstring());
1658-
1659-
#else // _WIN32
1660-
1661-
#define BufferValueToPath(str) std::filesystem::path(str.ToStringView());
1662-
#define PathToString(path) path.native();
1663-
1664-
#endif // _WIN32
1665-
16661617
static void RmSync(const FunctionCallbackInfo<Value>& args) {
16671618
Environment* env = Environment::GetCurrent(args);
16681619
Isolate* isolate = env->isolate();
@@ -2532,7 +2483,6 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
25322483
}
25332484
} else { // write(fd, string, pos, enc, undefined, ctx)
25342485
CHECK_EQ(argc, 6);
2535-
FSReqWrapSync req_wrap_sync;
25362486
FSReqBase::FSReqBuffer stack_buffer;
25372487
if (buf == nullptr) {
25382488
if (!StringBytes::StorageSize(isolate, value, enc).To(&len))
@@ -2546,6 +2496,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
25462496
buf = *stack_buffer;
25472497
}
25482498
uv_buf_t uvbuf = uv_buf_init(buf, len);
2499+
FSReqWrapSync req_wrap_sync("write");
25492500
FS_SYNC_TRACE_BEGIN(write);
25502501
int bytesWritten = SyncCall(env, args[5], &req_wrap_sync, "write",
25512502
uv_fs_write, fd, &uvbuf, 1, pos);
@@ -3195,6 +3146,42 @@ static void GetFormatOfExtensionlessFile(
31953146
return args.GetReturnValue().Set(EXTENSIONLESS_FORMAT_JAVASCRIPT);
31963147
}
31973148

3149+
#ifdef _WIN32
3150+
#define BufferValueToPath(str) \
3151+
std::filesystem::path(ConvertToWideString(str.ToString(), CP_UTF8))
3152+
3153+
std::string ConvertWideToUTF8(const std::wstring& wstr) {
3154+
if (wstr.empty()) return std::string();
3155+
3156+
int size_needed = WideCharToMultiByte(CP_UTF8,
3157+
0,
3158+
&wstr[0],
3159+
static_cast<int>(wstr.size()),
3160+
nullptr,
3161+
0,
3162+
nullptr,
3163+
nullptr);
3164+
std::string strTo(size_needed, 0);
3165+
WideCharToMultiByte(CP_UTF8,
3166+
0,
3167+
&wstr[0],
3168+
static_cast<int>(wstr.size()),
3169+
&strTo[0],
3170+
size_needed,
3171+
nullptr,
3172+
nullptr);
3173+
return strTo;
3174+
}
3175+
3176+
#define PathToString(path) ConvertWideToUTF8(path.wstring());
3177+
3178+
#else // _WIN32
3179+
3180+
#define BufferValueToPath(str) std::filesystem::path(str.ToStringView());
3181+
#define PathToString(path) path.native();
3182+
3183+
#endif // _WIN32
3184+
31983185
static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
31993186
Environment* env = Environment::GetCurrent(args);
32003187
Isolate* isolate = env->isolate();

0 commit comments

Comments
 (0)