cpclib_runner/runner/emulator/
cpcec.rs

1use std::sync::OnceLock;
2
3use cpclib_common::camino::Utf8PathBuf;
4
5use crate::delegated::{
6    ArchiveFormat, DownloadableInformation, ExecutableInformation,
7    InternetStaticCompiledApplication, MutiplatformUrls, StaticInformation
8};
9
10pub const CPCEC_CMD: &str = "cpcec";
11
12#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
13pub enum CpcecVersion {
14    #[default]
15    V20240505
16}
17
18impl InternetStaticCompiledApplication for CpcecVersion {}
19
20impl ExecutableInformation for CpcecVersion {
21    fn target_os_folder(&self) -> &'static str {
22        match self {
23            CpcecVersion::V20240505 => "cpcec20240505"
24        }
25    }
26
27    fn target_os_exec_fname(&self) -> &'static str {
28        "CPCEC.EXE"
29    }
30}
31
32impl StaticInformation for CpcecVersion {
33    fn static_download_urls(&self) -> &'static MutiplatformUrls {
34        static URL: OnceLock<MutiplatformUrls> = OnceLock::new();
35
36        URL.get_or_init(|| {
37            MutiplatformUrls::unique_url(match self {
38                CpcecVersion::V20240505 => "http://cngsoft.no-ip.org/cpcec-20240505.zip"
39            })
40        })
41    }
42}
43
44impl DownloadableInformation for CpcecVersion {
45    fn target_os_archive_format(&self) -> ArchiveFormat {
46        ArchiveFormat::Zip
47    }
48}
49
50impl CpcecVersion {
51    pub fn roms_folder(&self) -> Utf8PathBuf {
52        let conf = self.configuration::<()>();
53        conf.cache_folder()
54    }
55}