MCPcopy Create free account
hub / github.com/bootc-dev/bootc / check_utf8

Function check_utf8

crates/lib/src/lints.rs:512–534  ·  view source on GitHub ↗
(e: &WalkComponent, _config: &LintExecutionConfig)

Source from the content-addressed store, hash-verified

510 f: LintFnTy::Recursive(check_utf8),
511};
512fn check_utf8(e: &WalkComponent, _config: &LintExecutionConfig) -> LintRecursiveResult {
513 let path = e.path;
514 let filename = e.filename;
515 let dirname = path.parent().unwrap_or(Path::new("/"));
516 if filename.to_str().is_none() {
517 // This escapes like "abc\xFFdéf"
518 return lint_err(format!(
519 "{}: Found non-utf8 filename {filename:?}",
520 PathQuotedDisplay::new(&dirname)
521 ));
522 };
523
524 if e.file_type.is_symlink() {
525 let target = e.dir.read_link_contents(filename)?;
526 if target.to_str().is_none() {
527 return lint_err(format!(
528 "{}: Found non-utf8 symlink target",
529 PathQuotedDisplay::new(&path)
530 ));
531 }
532 }
533 lint_ok()
534}
535
536fn check_prepareroot_composefs_norecurse(dir: &Dir) -> LintResult {
537 let path = ostree_ext::ostree_prepareroot::CONF_PATH;

Callers

nothing calls this directly

Calls 3

lint_errFunction · 0.85
lint_okFunction · 0.85
to_strMethod · 0.80

Tested by

no test coverage detected