Skip to main content

is_reserved_device_name

Function is_reserved_device_name 

pub fn is_reserved_device_name(name: impl AsRef<OsStr>) -> bool
Expand description

Whether name matches a reserved Windows device name (e.g. CON, NUL, COM1, LPT9), independent of the current platform.

Accepts any OS-string-like value (&str, String, &OsStr, &Path, …), mirroring how the path helpers in this module take AsRef<Path>.

This answers a property of the name, not of the running OS: on a Windows host such a name resolves to a device rather than a file, so it must be rejected when mapping untrusted input to the filesystem (see the normal-component validator, which only consults it on Windows). Exposed so other crates can reuse the exact same check instead of duplicating it.