|
@@ -10,7 +10,7 @@ pub enum FileType {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl FileType {
|
|
impl FileType {
|
|
|
- pub fn get_all(dir: PathBuf) -> Vec<FileType> {
|
|
|
|
|
|
|
+ pub fn from_dir(dir: PathBuf) -> Vec<FileType> {
|
|
|
let entries = fs::read_dir(dir).expect("Create failed");
|
|
let entries = fs::read_dir(dir).expect("Create failed");
|
|
|
let mut files = Vec::new();
|
|
let mut files = Vec::new();
|
|
|
|
|
|
|
@@ -18,7 +18,7 @@ impl FileType {
|
|
|
let path = entry.expect("Failed to read directory").path();
|
|
let path = entry.expect("Failed to read directory").path();
|
|
|
|
|
|
|
|
if path.is_dir() {
|
|
if path.is_dir() {
|
|
|
- files.append(&mut FileType::get_all(path));
|
|
|
|
|
|
|
+ files.append(&mut FileType::from_dir(path));
|
|
|
} else if path.is_file() {
|
|
} else if path.is_file() {
|
|
|
let filename = path.file_name().expect("Error reading file").to_string_lossy();
|
|
let filename = path.file_name().expect("Error reading file").to_string_lossy();
|
|
|
|
|
|
|
@@ -38,4 +38,13 @@ impl FileType {
|
|
|
|
|
|
|
|
files
|
|
files
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ pub fn path(&self) -> &PathBuf {
|
|
|
|
|
+ match self {
|
|
|
|
|
+ FileType::HtmlIndex(p) => p,
|
|
|
|
|
+ FileType::NeovanIndex(p) => p,
|
|
|
|
|
+ FileType::HtmlComponent(p) => p,
|
|
|
|
|
+ FileType::NeovanComponent(p) => p
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|