mirror of
https://github.com/denoland/deno.git
synced 2025-01-20 20:42:19 -05:00
Merge f436751d16
into 0d3d4f5466
This commit is contained in:
commit
453514a54d
2 changed files with 69 additions and 2 deletions
|
@ -1063,7 +1063,7 @@ fn open_options(options: OpenOptions) -> fs::OpenOptions {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn open_with_access_check(
|
||||
pub fn open_with_access_check(
|
||||
options: OpenOptions,
|
||||
path: &Path,
|
||||
access_check: Option<AccessCheckCb>,
|
||||
|
@ -1071,7 +1071,11 @@ fn open_with_access_check(
|
|||
if let Some(access_check) = access_check {
|
||||
let path_bytes = path.as_os_str().as_encoded_bytes();
|
||||
let is_windows_device_path = cfg!(windows)
|
||||
&& path_bytes.starts_with(br"\\.\")
|
||||
&& (path_bytes.starts_with(br"\\.\")
|
||||
|| path_bytes.starts_with(b"//./")
|
||||
|| path_bytes.starts_with(b"//?/")
|
||||
|| path_bytes.starts_with(br"\\?\")
|
||||
|| path_bytes.ends_with(b"$"))
|
||||
&& !path_bytes.contains(&b':');
|
||||
let path = if is_windows_device_path {
|
||||
// On Windows, normalize_path doesn't work with device-prefix-style
|
||||
|
|
63
tests/specs/eval/check_device_paths/__test__.jsonc
Normal file
63
tests/specs/eval/check_device_paths/__test__.jsonc
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"tests": {
|
||||
"valid_device_paths": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('CONOUT$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: true }\n"
|
||||
},
|
||||
"valid_device_paths_i": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('CONIN$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: true }\n"
|
||||
},
|
||||
"valid_device_paths_with_prefix": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//./CONOUT$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: true }\n"
|
||||
},
|
||||
"valid_device_paths_with_prefix_i": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//./CONIN$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: true }\n"
|
||||
},
|
||||
"valid_device_paths_with_prefix_ii": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//?/CONIN$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: true }\n"
|
||||
},
|
||||
"valid_device_paths_with_prefix_iii": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//?/CONOUT$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: true }\n"
|
||||
},
|
||||
"valid_device_paths_nul_i": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//./NUL',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: false }\n"
|
||||
},
|
||||
"valid_device_paths_nul_ii": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//?/NUL',{read:true,write:true}).isTerminal()})",
|
||||
"output": "{ isTTY: false }\n"
|
||||
},
|
||||
"invalid_device_paths": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('\\\\.\\INVALID$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "error: Uncaught (in promise) NotFound: The system cannot find the file specified. (os error 2): open '\\.INVALID$'\n[WILDCARD]",
|
||||
"exitCode": 1
|
||||
},
|
||||
"invalid_device_paths_i": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('//./INVALID$',{read:true,write:true}).isTerminal()})",
|
||||
"output": "error: Uncaught (in promise) NotFound: The system cannot find the file specified. (os error 2): open '//./INVALID$'\n[WILDCARD]",
|
||||
"exitCode": 1
|
||||
},
|
||||
"invalid_device_paths_ii": {
|
||||
"if": "windows",
|
||||
"args": "eval console.log({isTTY:Deno.openSync('C:\\Invalid\\Path',{read:true,write:true}).isTerminal()})",
|
||||
"output": "error: Uncaught (in promise) NotFound: The system cannot find the file specified. (os error 2): open 'C:InvalidPath'\n[WILDCARD]",
|
||||
"exitCode": 1
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue