cpclib_runner/runner/emulator/
cpcemupower.rs

1const URL: &str =
2    "https://www.cpc-power.com/cpcarchives/download/Emulateurs/20210531_CPCEPower_SDL_Release.zip";
3
4use std::sync::OnceLock;
5
6use crate::delegated::{
7    ArchiveFormat, DownloadableInformation, ExecutableInformation,
8    InternetStaticCompiledApplication, MutiplatformUrls, StaticInformation
9};
10use crate::runner::runner::RunInDir;
11
12pub const CPCEMUPOWER_CMD: &str = "cpcemupower";
13
14#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
15pub enum CpcEmuPowerVersion {
16    #[default]
17    R20210531
18}
19
20impl InternetStaticCompiledApplication for CpcEmuPowerVersion {}
21
22impl ExecutableInformation for CpcEmuPowerVersion {
23    fn target_os_folder(&self) -> &'static str {
24        match self {
25            Self::R20210531 => "20210531_CPCEPower_SDL_Release"
26        }
27    }
28
29    fn target_os_exec_fname(&self) -> &'static str {
30        match self {
31            Self::R20210531 => {
32                #[cfg(target_os = "windows")]
33                return "CPCEPower_SDL_x64.exe";
34                #[cfg(target_os = "linux")]
35                return "CPCEPower_SDL_Linux_x64";
36                #[cfg(target_os = "macosx")]
37                return "CPCEPower_SDL_MacOS";
38            }
39        }
40    }
41
42    fn target_os_run_in_dir(&self) -> RunInDir {
43        RunInDir::AppDir
44    }
45}
46
47impl StaticInformation for CpcEmuPowerVersion {
48    fn static_download_urls(&self) -> &'static MutiplatformUrls {
49        match self {
50            CpcEmuPowerVersion::R20210531 => {
51                static URLS: OnceLock<MutiplatformUrls> = OnceLock::new();
52                URLS.get_or_init(|| MutiplatformUrls::unique_url(URL))
53            }
54        }
55    }
56}
57
58impl DownloadableInformation for CpcEmuPowerVersion {
59    fn target_os_archive_format(&self) -> ArchiveFormat {
60        ArchiveFormat::Zip
61    }
62
63    // fn target_os_postinstall<E: EventObserver>(&self) -> Option<crate::delegated::PostInstall<E>> {
64    // let owned_original = match self {
65    // CpcEmuPowerVersion::R20210531 => {
66    // "CPC_AMSpiriT_RC_v1.01_Win_x64/Amspirit v1.01_RC_x64.exe".to_owned()
67    // },
68    // };
69    // let owned_result = self.target_os_exec_fname().to_owned();
70    //
71    // let post_install: Box<dyn Fn(&DelegateApplicationDescription<E>) -> Result<(), String>> =
72    // Box::new(move |d: &DelegateApplicationDescription<E>| {
73    // std::fs::rename(
74    // d.cache_folder().join(&owned_original),
75    // d.cache_folder().join(&owned_result)
76    // )
77    // .map_err(|e| e.to_string())
78    // });
79    //
80    // Some(post_install.into())
81    // }
82}