use anyhow::Result;
use bezel::{
gpui::{AssetSource, SharedString},
ui::icons,
};
use std::{borrow::Cow, path::PathBuf};
pub fn mark() -> Option<PathBuf> {
let exe = std::env::current_exe().ok()?;
let bundled = exe.parent()?.parent()?.join("Resources").join("icon.png");
let source = PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/icon.png"));
[bundled, source].into_iter().find(|path| path.is_file())
}
pub struct Assets;
impl AssetSource for Assets {
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
if let Some(bytes) = icons::Assets.load(path)? {
return Ok(Some(bytes));
}
Ok(std::fs::read(path).ok().map(Cow::Owned))
}
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
icons::Assets.list(path)
}
}