MCPcopy Create free account
hub / github.com/archlinux/alpm / filenames_in_dir

Function filenames_in_dir

dev-scripts/src/sync/mod.rs:37–54  ·  view source on GitHub ↗

A small helper function that returns a list of unique file names in a directory.

(path: &Path)

Source from the content-addressed store, hash-verified

35
36/// A small helper function that returns a list of unique file names in a directory.
37pub fn filenames_in_dir(path: &Path) -> Result<HashSet<String>, Error> {
38 let entries = read_dir(path).map_err(|source| Error::IoPath {
39 path: path.to_path_buf(),
40 context: "retrieving the entries of the directory".to_string(),
41 source,
42 })?;
43 let mut files: HashSet<String> = HashSet::new();
44 for entry in entries {
45 let entry = entry.map_err(|source| Error::IoPath {
46 path: path.to_path_buf(),
47 context: "retrieving an entry in the directory".to_string(),
48 source,
49 })?;
50 files.insert(entry.file_name().to_string_lossy().to_string());
51 }
52
53 Ok(files)
54}

Callers 2

remove_old_reposMethod · 0.85
sync_remote_packagesMethod · 0.85

Calls 1

to_path_bufMethod · 0.45

Tested by

no test coverage detected