use std::path::PathBuf;

use crate::{config::Config, error::Error};

pub fn find_library(config: &Config, name: &str) -> Result<PathBuf, Error> {
    for search_path in config.search_paths.iter() {
        let path = search_path.join(name);
        if path.exists() {
            return Ok(path);
        }
    }
    Err(Error::LibraryNotFound(name.to_owned()))
}
