[][src]Function grin_store::pmmr::clean_files_by_prefix

pub fn clean_files_by_prefix<P: AsRef<Path>>(
    path: P,
    prefix_to_delete: &str,
    cleanup_duration_seconds: u64
) -> Result<u32>

Quietly clean a directory up based on a given prefix. If the file was accessed within cleanup_duration_seconds from the beginning of the function call, it will not be deleted. To delete all files, set cleanup_duration_seconds to zero.

Precondition is that path points to a directory.

If you have files such as

foo
foo.1
foo.2
.
.
.
.
.

call this function and you will get

foo

in the directory

The return value will be the number of files that were deleted.

This function will return an error whenever the call to std;:fs::read_dir fails on the given path for any reason.