#![forbid(unsafe_code)]
use crate::error_handler::Error;
use std::{fs, path::Path};
pub fn get_file_names_in_directory(directory: &Path) -> Result<Vec<String>, Error> {
let mut found_file_names = Vec::<String>::new();
for entry in fs::read_dir(directory)? {
let path = entry?.path();
if path.is_dir() {
continue;
}
if let Some(os_path) = path.file_name() {
found_file_names.push(os_path.to_str().unwrap().to_string());
}
}
match found_file_names.is_empty() {
true => Err(Error::NoFilesFound),
false => Ok(found_file_names),
}
}