Skip to main content

safe_file_name

Function safe_file_name 

Source
pub fn safe_file_name(name: &str) -> Option<Cow<'_, str>>
Expand description

The camera’s file name made safe to use as one path component on every platform, or None where it cannot be.

A camera is an untrusted peer. A name that is empty, . or .., longer than 255 bytes, or holds a separator, NUL or another control character is refused, and the caller names the file after its handle instead. A name that is otherwise usable but invalid on Windows is repaired so it keeps its extension: each of : * ? " < > | becomes _, trailing dots and spaces (which Windows strips) become _, and a reserved device name (CON, PRN, AUX, NUL, COM1-COM9, LPT1-LPT9, with or without an extension) gains a leading _. A repaired name can equal another object’s real name; the identity record keeps the two apart.