use crate::{ResError, ResWriter, Resource, util};
use std::path::PathBuf;
pub struct Icon {
id: String,
path: PathBuf,
}
impl Icon {
pub fn new<N, P>(id: N, path: P) -> Self
where
N: ToString,
P: Into<PathBuf>,
{
Self {
id: id.to_string(),
path: path.into(),
}
}
pub fn app<P: Into<PathBuf>>(path: P) -> Self {
Self::new(32512, path)
}
}
impl Resource for Icon {
fn write(&self, writer: &mut ResWriter) -> Result<(), ResError> {
writer.line(format!(
"{} ICON \"{}\"",
self.id,
util::escape_path(&self.path)?
));
Ok(())
}
}