20 lines
535 B
Rust
20 lines
535 B
Rust
use anyhow::Result;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
pub fn discover(recipe_dir: &Path) -> Result<Vec<PathBuf>> {
|
|
let patch_dir = recipe_dir.join("patches");
|
|
if !patch_dir.exists() {
|
|
return Ok(Vec::new());
|
|
}
|
|
let mut patches = Vec::new();
|
|
for entry in std::fs::read_dir(&patch_dir)? {
|
|
let entry = entry?;
|
|
let path = entry.path();
|
|
if path.extension().and_then(|ext| ext.to_str()) == Some("patch") {
|
|
patches.push(path);
|
|
}
|
|
}
|
|
patches.sort();
|
|
Ok(patches)
|
|
}
|