cpclib_runner/runner/emulator/
caprice_forever.rs

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