18 lines
538 B
Rust
18 lines
538 B
Rust
use std::{fs, io};
|
|
use std::path::Path;
|
|
|
|
pub fn list_of_files_in_directory(root_directory: &Path) -> String {
|
|
|
|
let mut return_value = String::new();
|
|
|
|
if root_directory.is_dir() {
|
|
for entry in fs::read_dir(root_directory).unwrap() {
|
|
let entry = entry.unwrap();
|
|
let path = entry.path();
|
|
if path.is_file() {
|
|
return_value = format!("{}\n{}", return_value, path.file_name().unwrap().to_string_lossy());
|
|
}
|
|
}
|
|
}
|
|
return_value
|
|
} |