Function filetools::list_files
source · pub async fn list_files<P: AsRef<Path> + Send>(path: P) -> Result<Vec<PathBuf>>
Expand description
Lists all files in the given directory (not including subdirectories).
§Sync
For the sync
version, see crate::sync::list_files
§Errors
This function will return an error in the following situations:
- The path given is a file and not a directory
- The given path does not exist
§Example
use filetools::list_files;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let target_folder = "folder/containing/files";
// Will return a Vec containing all files in the folder
let files = list_files(target_folder).await?;
Ok(())
}