mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2026-01-19 11:41:10 +00:00
bytes operation for pathchk
This commit is contained in:
parent
def5bec1ce
commit
1fecd98ebe
1 changed files with 5 additions and 4 deletions
|
|
@ -241,13 +241,14 @@ fn no_leading_hyphen(path_segment: &str) -> bool {
|
|||
|
||||
// check whether a path segment contains only valid (read: portable) characters
|
||||
fn check_portable_chars(path_segment: &str) -> bool {
|
||||
let valid_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-".to_string();
|
||||
for ch in path_segment.chars() {
|
||||
if !valid_str.contains(ch) {
|
||||
const VALID_CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-";
|
||||
for (i, ch) in path_segment.as_bytes().iter().enumerate() {
|
||||
if !VALID_CHARS.contains(ch) {
|
||||
let invalid = path_segment[i..].chars().next().unwrap();
|
||||
writeln!(
|
||||
&mut std::io::stderr(),
|
||||
"nonportable character '{}' in file name component '{}'",
|
||||
ch,
|
||||
invalid,
|
||||
path_segment
|
||||
);
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue