GeezerVison is showing github.com — src: move windows specific fns to `_WIN32` · nodejs/node@2877207
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/util-inl.h +5-7Lines changed: 5 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
28 | 28 | #include <cstring> |
29 | 29 | #include <locale> |
30 | 30 | #include <ranges> |
31 | | -#include <regex> // NOLINT(build/c++11) |
32 | 31 | #include "node_revert.h" |
33 | 32 | #include "util.h" |
34 | 33 |
|
| 34 | +#ifdef _WIN32 |
| 35 | +#include <regex> // NOLINT(build/c++11) |
| 36 | +#endif // _WIN32 |
| 37 | + |
35 | 38 | #define CHAR_TEST(bits, name, expr) \ |
36 | 39 | template <typename T> \ |
37 | 40 | bool name(const T ch) { \ |
@@ -588,9 +591,8 @@ constexpr std::string_view FastStringKey::as_string_view() const { |
588 | 591 | return name_; |
589 | 592 | } |
590 | 593 |
|
591 | | -// Inline so the compiler can fully optimize it away on Unix platforms. |
592 | | -bool IsWindowsBatchFile(const char* filename) { |
593 | 594 | #ifdef _WIN32 |
| 595 | +inline bool IsWindowsBatchFile(const char* filename) { |
594 | 596 | std::string file_with_extension = filename; |
595 | 597 | // Regex to match the last extension part after the last dot, ignoring |
596 | 598 | // trailing spaces and dots |
@@ -603,12 +605,8 @@ bool IsWindowsBatchFile(const char* filename) { |
603 | 605 | } |
604 | 606 |
|
605 | 607 | return !extension.empty() && (extension == "cmd" || extension == "bat"); |
606 | | -#else |
607 | | - return false; |
608 | | -#endif // _WIN32 |
609 | 608 | } |
610 | 609 |
|
611 | | -#ifdef _WIN32 |
612 | 610 | inline std::wstring ConvertToWideString(const std::string& str, |
613 | 611 | UINT code_page) { |
614 | 612 | int size_needed = MultiByteToWideChar( |
|
Collapse file
Copy file name to clipboardExpand all lines: src/util.h +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1026,9 +1026,12 @@ v8::Maybe<int> GetValidFileMode(Environment* env, |
1026 | 1026 | v8::Local<v8::Value> input, |
1027 | 1027 | uv_fs_type type); |
1028 | 1028 |
|
| 1029 | +#ifdef _WIN32 |
1029 | 1030 | // Returns true if OS==Windows and filename ends in .bat or .cmd, |
1030 | 1031 | // case insensitive. |
1031 | 1032 | inline bool IsWindowsBatchFile(const char* filename); |
| 1033 | +inline std::wstring ConvertToWideString(const std::string& str, UINT code_page); |
| 1034 | +#endif // _WIN32 |
1032 | 1035 |
|
1033 | 1036 | } // namespace node |
1034 | 1037 |
|
|