File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,11 @@ var winislocaltests = []IsLocalTest{
174
174
{`C:` , false },
175
175
{`C:\a` , false },
176
176
{`..\a` , false },
177
+ {`CONIN$` , false },
178
+ {`conin$` , false },
179
+ {`CONOUT$` , false },
180
+ {`conout$` , false },
181
+ {`dollar$` , true }, // not a special file name
177
182
}
178
183
179
184
var plan9islocaltests = []IsLocalTest {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ func toUpper(c byte) byte {
20
20
return c
21
21
}
22
22
23
- // isReservedName reports if name is a Windows reserved device name.
23
+ // isReservedName reports if name is a Windows reserved device name or a console handle .
24
24
// It does not detect names with an extension, which are also reserved on some Windows versions.
25
25
//
26
26
// For details, search for PRN in
@@ -34,6 +34,17 @@ func isReservedName(name string) bool {
34
34
return len (name ) == 4 && '1' <= name [3 ] && name [3 ] <= '9'
35
35
}
36
36
}
37
+ // Passing CONIN$ or CONOUT$ to CreateFile opens a console handle.
38
+ // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#consoles
39
+ //
40
+ // While CONIN$ and CONOUT$ aren't documented as being files,
41
+ // they behave the same as CON. For example, ./CONIN$ also opens the console input.
42
+ if len (name ) == 6 && name [5 ] == '$' && strings .EqualFold (name , "CONIN$" ) {
43
+ return true
44
+ }
45
+ if len (name ) == 7 && name [6 ] == '$' && strings .EqualFold (name , "CONOUT$" ) {
46
+ return true
47
+ }
37
48
return false
38
49
}
39
50
You can’t perform that action at this time.
0 commit comments