Skip to content

Commit 1720b18

Browse files
authored
src: move windows specific fns to _WIN32
PR-URL: nodejs#57951 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Stefan Stojanovic <[email protected]>
1 parent 1c0a405 commit 1720b18

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/util-inl.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
#include <cstring>
2929
#include <locale>
3030
#include <ranges>
31-
#include <regex> // NOLINT(build/c++11)
3231
#include "node_revert.h"
3332
#include "util.h"
3433

34+
#ifdef _WIN32
35+
#include <regex> // NOLINT(build/c++11)
36+
#endif // _WIN32
37+
3538
#define CHAR_TEST(bits, name, expr) \
3639
template <typename T> \
3740
bool name(const T ch) { \
@@ -588,9 +591,8 @@ constexpr std::string_view FastStringKey::as_string_view() const {
588591
return name_;
589592
}
590593

591-
// Inline so the compiler can fully optimize it away on Unix platforms.
592-
bool IsWindowsBatchFile(const char* filename) {
593594
#ifdef _WIN32
595+
inline bool IsWindowsBatchFile(const char* filename) {
594596
std::string file_with_extension = filename;
595597
// Regex to match the last extension part after the last dot, ignoring
596598
// trailing spaces and dots
@@ -603,12 +605,8 @@ bool IsWindowsBatchFile(const char* filename) {
603605
}
604606

605607
return !extension.empty() && (extension == "cmd" || extension == "bat");
606-
#else
607-
return false;
608-
#endif // _WIN32
609608
}
610609

611-
#ifdef _WIN32
612610
inline std::wstring ConvertToWideString(const std::string& str,
613611
UINT code_page) {
614612
int size_needed = MultiByteToWideChar(

src/util.h

+3
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,12 @@ v8::Maybe<int> GetValidFileMode(Environment* env,
10261026
v8::Local<v8::Value> input,
10271027
uv_fs_type type);
10281028

1029+
#ifdef _WIN32
10291030
// Returns true if OS==Windows and filename ends in .bat or .cmd,
10301031
// case insensitive.
10311032
inline bool IsWindowsBatchFile(const char* filename);
1033+
inline std::wstring ConvertToWideString(const std::string& str, UINT code_page);
1034+
#endif // _WIN32
10321035

10331036
} // namespace node
10341037

0 commit comments

Comments
 (0)