pub fn init_static(
    resources: &mut Resources,
    settings: &mut Settings,
    stdout: &mut Stdout,
) -> Result<(), Box<dyn Error>> {
    //load other resource file
    resources.other = res::get_serde_json("tool_config_files/other.json", stdout)?;

    // build resource section vector
    let config_res_sections: Vec<(String, String, String, String)> =
        serde_json::from_value(resources.octool_config["resource_sections"].clone()).unwrap();
    for (mut sec, sub, _, _) in config_res_sections {
        sec.push_str(&sub);
        settings.resource_sections.push(sec);
    }

    //load resources list file
    resources.resource_list = res::get_serde_json("tool_config_files/resource_list.json", stdout)?;

    //load dortania build_repo package
    write!(
        stdout,
        "\r\n\x1B[32mChecking\x1B[0m local dortania/build_repo/config.json\r\n"
    )?;
    let path = Path::new(
        resources.octool_config["dortania_config_path"]
            .as_str()
            .unwrap(),
    );
    let url = resources.octool_config["dortania_config_zip"]
        .as_str()
        .unwrap();
    if !path.exists() {
        write!(stdout, "\x1b[32mDownloading\x1B[0m latest config.json ... ")?;
        stdout.flush().unwrap();
        let path = path.parent().unwrap().join("builds.zip");
        res::curl_file(&url, &path)?;
        let z_file = std::fs::File::open(&path)?;
        let mut z_archive = zip::ZipArchive::new(z_file)?;
        match z_archive.extract(&path.parent().unwrap()) {
            Ok(_) => std::fs::remove_file(&path)?,
            Err(e) => panic!("{:?}", e),
        }
        write!(stdout, "\x1b[32mdone\x1b[0m\r\n")?
    } else {
        let path = path.parent().unwrap();
        let mut old_size = 0;
        let mut current_size = 1;
        let file_path = &path.join("build-repo-builds").join("size.json");
        if file_path.exists() {
            let size_file = File::open(&file_path)?;
            let buf = BufReader::new(size_file);
            let size: serde_json::Value = serde_json::from_reader(buf)?;
            old_size = size["tree"][0]["size"].as_i64().unwrap();
            current_size = res::curl_build_size(&file_path)?;
        } else {
            let _ = res::curl_build_size(&file_path)?;
        }
        #[cfg(debug_assertions)]
        {
            write!(
                stdout,
                "debug:  old {}  current {}\r\n",
                old_size, current_size
            )?;
        }

        if old_size != current_size {
            write!(stdout, "\x1b[32mDownloading\x1B[0m latest config.json ... ")?;
            stdout.flush().unwrap();
            let path = path.join("builds.zip");
            res::curl_file(&url, &path)?;
            let z_file = std::fs::File::open(&path)?;
            let mut z_archive = zip::ZipArchive::new(z_file)?;
            match z_archive.extract(&path.parent().unwrap()) {
                Ok(_) => std::fs::remove_file(&path)?,
                Err(e) => panic!("{:?}", e),
            }
            write!(stdout, "\x1b[32mdone\x1b[0m\r\n")?
        } else {
            write!(stdout, "Already up to date.\r\n")?;
        }
    };
    resources.dortania = res::get_serde_json(path.join("config.json").to_str().unwrap(), stdout)?;

    Ok(())
}
/// load static resources into resources struct, shouldn't need to change even if user
/// changes opencore build version on the fly
load static resources into resources struct, shouldn't need to change even if user
changes opencore build version on the fly
load static resources into resources struct shouldn ' t need to change even if user changes opencore build version on the fly
pub fn init_static(
    resources: &mut Resources,
    settings: &mut Settings,
    stdout: &mut Stdout,
) -> Result<(), Box<dyn Error>> {
    //load other resource file
    resources.other = res::get_serde_json("tool_config_files/other.json", stdout)?;
    // build resource section vector
    let config_res_sections: Vec<(String, String, String, String)> =
        serde_json::from_value(resources.octool_config["resource_sections"].clone()).unwrap();
    for (mut sec, sub, _, _) in config_res_sections {
        sec.push_str(&sub);
        settings.resource_sections.push(sec);
    }
    //load resources list file
    resources.resource_list = res::get_serde_json("tool_config_files/resource_list.json", stdout)?;
    //load dortania build_repo package
    write!(
        stdout,
        "\r\n\x1B[32mChecking\x1B[0m local dortania/build_repo/config.json\r\n"
    )?;
    let path = Path::new(
        resources.octool_config["dortania_config_path"]
            .as_str()
            .unwrap(),
    );
    let url = resources.octool_config["dortania_config_zip"]
        .as_str()
        .unwrap();
    if !path.exists() {
        write!(stdout, "\x1b[32mDownloading\x1B[0m latest config.json ... ")?;
        stdout.flush().unwrap();
        let path = path.parent().unwrap().join("builds.zip");
        res::curl_file(&url, &path)?;
        let z_file = std::fs::File::open(&path)?;
        let mut z_archive = zip::ZipArchive::new(z_file)?;
        match z_archive.extract(&path.parent().unwrap()) {
            Ok(_) => std::fs::remove_file(&path)?,
            Err(e) => panic!("{:?}", e),
        }
        write!(stdout, "\x1b[32mdone\x1b[0m\r\n")?
    } else {
        let path = path.parent().unwrap();
        let mut old_size = 0;
        let mut current_size = 1;
        let file_path = &path.join("build-repo-builds").join("size.json");
        if file_path.exists() {
            let size_file = File::open(&file_path)?;
            let buf = BufReader::new(size_file);
            let size: serde_json::Value = serde_json::from_reader(buf)?;
            old_size = size["tree"][0]["size"].as_i64().unwrap();
            current_size = res::curl_build_size(&file_path)?;
        } else {
            let _ = res::curl_build_size(&file_path)?;
        }
        #[cfg(debug_assertions)]
        {
            write!(
                stdout,
                "debug:  old {}  current {}\r\n",
                old_size, current_size
            )?;
        }
        if old_size != current_size {
            write!(stdout, "\x1b[32mDownloading\x1B[0m latest config.json ... ")?;
            stdout.flush().unwrap();
            let path = path.join("builds.zip");
            res::curl_file(&url, &path)?;
            let z_file = std::fs::File::open(&path)?;
            let mut z_archive = zip::ZipArchive::new(z_file)?;
            match z_archive.extract(&path.parent().unwrap()) {
                Ok(_) => std::fs::remove_file(&path)?,
                Err(e) => panic!("{:?}", e),
            }
            write!(stdout, "\x1b[32mdone\x1b[0m\r\n")?
        } else {
            write!(stdout, "Already up to date.\r\n")?;
        }
    };
    resources.dortania = res::get_serde_json(path.join("config.json").to_str().unwrap(), stdout)?;
    Ok(())
}
pub fn init_static ( resources : & mut Resources , settings : & mut Settings , stdout : & mut Stdout , ) -> Result < ( ) , Box < dyn Error > > { //load other resource file resources . other = res :: get_serde_json ( " " , stdout ) ? ; // build resource section vector let config_res_sections : Vec < ( String , String , String , String ) > = serde_json :: from_value ( resources . octool_config [ " " ] . clone ( ) ) . unwrap ( ) ; for ( mut sec , sub , _ , _ ) in config_res_sections { sec . push_str ( & sub ) ; settings . resource_sections . push ( sec ) ; } //load resources list file resources . resource_list = res :: get_serde_json ( " " , stdout ) ? ; //load dortania build_repo package write ! ( stdout " \r \n \x1B \x1B \r \n " ) ? ; let path = Path :: new ( resources . octool_config [ " " ] . as_str ( ) . unwrap ( ) , ) ; let url = resources . octool_config [ " " ] . as_str ( ) . unwrap ( ) ; if ! path . exists ( ) { write ! ( stdout " \x1b \x1B " ) ? ; stdout . flush ( ) . unwrap ( ) ; let path = path . parent ( ) . unwrap ( ) . join ( " " ) ; res :: curl_file ( & url , & path ) ? ; let z_file = std :: fs :: File :: open ( & path ) ? ; let mut z_archive = zip :: ZipArchive :: new ( z_file ) ? ; match z_archive . extract ( & path . parent ( ) . unwrap ( ) ) { Ok ( _ ) => std :: fs :: remove_file ( & path ) ? , Err ( e ) => panic ! ( " " e ) , } write ! ( stdout " \x1b \x1b \r \n " ) ? } else { let path = path . parent ( ) . unwrap ( ) ; let mut old_size = 0 ; let mut current_size = 1 ; let file_path = & path . join ( " " ) . join ( " " ) ; if file_path . exists ( ) { let size_file = File :: open ( & file_path ) ? ; let buf = BufReader :: new ( size_file ) ; let size : serde_json :: Value = serde_json :: from_reader ( buf ) ? ; old_size = size [ " " ] [ 0 ] [ " " ] . as_i64 ( ) . unwrap ( ) ; current_size = res :: curl_build_size ( & file_path ) ? ; } else { let _ = res :: curl_build_size ( & file_path ) ? ; } # [ cfg ( debug_assertions ) ] { write ! ( stdout " \r \n " old_size current_size ) ? ; } if old_size != current_size { write ! ( stdout " \x1b \x1B " ) ? ; stdout . flush ( ) . unwrap ( ) ; let path = path . join ( " " ) ; res :: curl_file ( & url , & path ) ? ; let z_file = std :: fs :: File :: open ( & path ) ? ; let mut z_archive = zip :: ZipArchive :: new ( z_file ) ? ; match z_archive . extract ( & path . parent ( ) . unwrap ( ) ) { Ok ( _ ) => std :: fs :: remove_file ( & path ) ? , Err ( e ) => panic ! ( " " e ) , } write ! ( stdout " \x1b \x1b \r \n " ) ? } else { write ! ( stdout " \r \n " ) ? ; } } ; resources . dortania = res :: get_serde_json ( path . join ( " " ) . to_str ( ) . unwrap ( ) , stdout ) ? ; Ok ( ( ) ) }
load static resources into resources struct, shouldn't need to change even if user
changes opencore build version on the fly
load static resources into resources struct shouldn ' t need to change even if user changes opencore build version on the fly
resources
&mut Resources
settings
&mut Settings
stdout
&mut Stdout
resources
&mut Resources
settings
&mut Settings
stdout
&mut Stdout