Skip to content

Commit 41a11c8

Browse files
anonrigaduh95
authored andcommitted
src: move windows specific fns to _WIN32
PR-URL: #57951 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
1 parent 9c0a7a1 commit 41a11c8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/util-inl.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
#include <cmath>
2828
#include <cstring>
2929
#include <locale>
30-
#include <regex> // NOLINT(build/c++11)
3130
#include "node_revert.h"
3231
#include "util.h"
3332

33+
#ifdef _WIN32
34+
#include <regex> // NOLINT(build/c++11)
35+
#endif // _WIN32
36+
3437
#define CHAR_TEST(bits, name, expr) \
3538
template <typename T> \
3639
bool name(const T ch) { \
@@ -568,9 +571,8 @@ constexpr std::string_view FastStringKey::as_string_view() const {
568571
return name_;
569572
}
570573

571-
// Inline so the compiler can fully optimize it away on Unix platforms.
572-
bool IsWindowsBatchFile(const char* filename) {
573574
#ifdef _WIN32
575+
inline bool IsWindowsBatchFile(const char* filename) {
574576
std::string file_with_extension = filename;
575577
// Regex to match the last extension part after the last dot, ignoring
576578
// trailing spaces and dots
@@ -583,12 +585,8 @@ bool IsWindowsBatchFile(const char* filename) {
583585
}
584586

585587
return !extension.empty() && (extension == "cmd" || extension == "bat");
586-
#else
587-
return false;
588-
#endif // _WIN32
589588
}
590589

591-
#ifdef _WIN32
592590
inline std::wstring ConvertToWideString(const std::string& str,
593591
UINT code_page) {
594592
int size_needed = MultiByteToWideChar(

src/util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,12 @@ v8::Maybe<int> GetValidFileMode(Environment* env,
10211021
v8::Local<v8::Value> input,
10221022
uv_fs_type type);
10231023

1024+
#ifdef _WIN32
10241025
// Returns true if OS==Windows and filename ends in .bat or .cmd,
10251026
// case insensitive.
10261027
inline bool IsWindowsBatchFile(const char* filename);
1028+
inline std::wstring ConvertToWideString(const std::string& str, UINT code_page);
1029+
#endif // _WIN32
10271030

10281031
} // namespace node
10291032

0 commit comments

Comments
 (0)