From c0d8f9c3fd029093e6bd96c612352c80178ff8ae Mon Sep 17 00:00:00 2001 From: idealvin Date: Thu, 2 Nov 2023 23:06:11 +0800 Subject: [PATCH] fix compile error on windows --- src/fs_win.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fs_win.cc b/src/fs_win.cc index 834b76b2a..a5772fbbf 100644 --- a/src/fs_win.cc +++ b/src/fs_win.cc @@ -141,7 +141,8 @@ bool mkdir(char* path, bool p) { inline void pathcat(fastring& s, wchar_t c, const wchar_t* p) { const wchar_t z = L'\0'; - s.append(&c, sizeof(c)).append((char*)p).append(&z, sizeof(z)); + const size_t n = wcslen(p) * sizeof(wchar_t); + s.append(&c, sizeof(c)).append((char*)p, n).append(&z, sizeof(z)); s.resize(s.size() - sizeof(z)); } @@ -152,7 +153,7 @@ inline bool is_dot_or_dotdot(const wchar_t* p) { static bool _rmdir(fastring& s, wchar_t c) { const wchar_t* t = L"*"; const size_t n = s.size(); - pathcat(s, c, t) + pathcat(s, c, t); WIN32_FIND_DATAW e; HANDLE h = FindFirstFileW((PWC)s.data(), &e);