| 101 | } |
| 102 | |
| 103 | pub fn validate_dlc_name(name: &str) -> io::Result<()> { |
| 104 | let mut components = Path::new(name).components(); |
| 105 | let is_single_normal = |
| 106 | matches!(components.next(), Some(Component::Normal(_))) && components.next().is_none(); |
| 107 | if !is_single_normal || name.contains(['/', '\\', '"']) || name.chars().any(char::is_control) { |
| 108 | return Err(io::Error::new( |
| 109 | io::ErrorKind::InvalidInput, |
| 110 | "invalid dlc name", |
| 111 | )); |
| 112 | } |
| 113 | if is_reserved_dlc_name(name) { |
| 114 | return Err(io::Error::new( |
| 115 | io::ErrorKind::InvalidInput, |