| 59 | }; |
| 60 | |
| 61 | static bool isComPortPath(SC::StringSpan path) |
| 62 | { |
| 63 | SC::SmallString<32> asciiPath(SC::StringEncoding::Ascii); |
| 64 | if (not asciiPath.assign(path)) |
| 65 | { |
| 66 | return false; |
| 67 | } |
| 68 | SC::StringSpan asciiView = asciiPath.view(); |
| 69 | const char* parsed = asciiView.bytesWithoutTerminator(); |
| 70 | size_t length = asciiView.sizeInBytes(); |
| 71 | |
| 72 | if (length == 0) |
| 73 | { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | if (length >= 4 and parsed[0] == '\\' and parsed[1] == '\\' and parsed[2] == '.' and parsed[3] == '\\') |
| 78 | { |
| 79 | parsed += 4; |
| 80 | length -= 4; |
| 81 | } |
| 82 | |
| 83 | if (length < 4 or not((parsed[0] == 'C' or parsed[0] == 'c') and (parsed[1] == 'O' or parsed[1] == 'o') and |
| 84 | (parsed[2] == 'M' or parsed[2] == 'm'))) |
| 85 | { |
| 86 | return false; |
| 87 | } |
| 88 | parsed += 3; |
| 89 | length -= 3; |
| 90 | if (length == 0) |
| 91 | { |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | for (size_t idx = 0; idx < length; ++idx) |
| 96 | { |
| 97 | const char c = parsed[idx]; |
| 98 | if (c < '0' or c > '9') |
| 99 | { |
| 100 | return false; |
| 101 | } |
| 102 | } |
| 103 | return true; |
| 104 | } |
| 105 | |
| 106 | static WindowsCom0ComPorts resolveWindowsCom0ComPorts() |
| 107 | { |
no test coverage detected