fn load_raw_source(path: String) -> Result<String, SimpleError> {
        if path.starts_with("@boop/") {
            // script is internal

            let internal_path = path.replace("@boop/", "lib/");
            info!(
                "found internal script, real path: #BINARY#/{}",
                internal_path
            );

            let raw_source = String::from_utf8(
                Scripts::get(&internal_path)
                    .ok_or_else(|| {
                        SimpleError::new(format!("no internal script with path \"{}\"", path))
                    })?
                    .to_vec(),
            )
            .map_err(|e| SimpleError::with("problem with file encoding", e))?;

            return Ok(raw_source);
        }

        let mut external_path = PROJECT_DIRS.config_dir().to_path_buf();
        external_path.push("scripts");
        external_path.push(&path);

        info!(
            "found external script, real path: {}",
            external_path.display()
        );

        let mut raw_source = String::new();
        File::open(external_path)
            .map_err(|e| SimpleError::with(&format!("could not open \"{}\"", path), e))?
            .read_to_string(&mut raw_source)
            .map_err(|e| SimpleError::with("problem reading file", e))?;

        Ok(raw_source)
    }
// load source code from internal files or external filesystem depending on the path
load source code from internal files or external filesystem depending on the path
load source code from internal files or external filesystem depending on the path
fn load_raw_source(path: String) -> Result<String, SimpleError> {
        if path.starts_with("@boop/") {
            // script is internal
            let internal_path = path.replace("@boop/", "lib/");
            info!(
                "found internal script, real path: #BINARY#/{}",
                internal_path
            );
            let raw_source = String::from_utf8(
                Scripts::get(&internal_path)
                    .ok_or_else(|| {
                        SimpleError::new(format!("no internal script with path \"{}\"", path))
                    })?
                    .to_vec(),
            )
            .map_err(|e| SimpleError::with("problem with file encoding", e))?;
            return Ok(raw_source);
        }
        let mut external_path = PROJECT_DIRS.config_dir().to_path_buf();
        external_path.push("scripts");
        external_path.push(&path);
        info!(
            "found external script, real path: {}",
            external_path.display()
        );
        let mut raw_source = String::new();
        File::open(external_path)
            .map_err(|e| SimpleError::with(&format!("could not open \"{}\"", path), e))?
            .read_to_string(&mut raw_source)
            .map_err(|e| SimpleError::with("problem reading file", e))?;
        Ok(raw_source)
    }
fn load_raw_source ( path : String ) -> Result < String , SimpleError > { if path . starts_with ( " " ) { // script is internal let internal_path = path . replace ( " " , " " ) ; info ! ( " " internal_path ) ; let raw_source = String :: from_utf8 ( Scripts :: get ( & internal_path ) . ok_or_else ( | | { SimpleError :: new ( format ! ( " \" \" " path ) ) } ) ? . to_vec ( ) , ) . map_err ( | e | SimpleError :: with ( " " , e ) ) ? ; return Ok ( raw_source ) ; } let mut external_path = PROJECT_DIRS . config_dir ( ) . to_path_buf ( ) ; external_path . push ( " " ) ; external_path . push ( & path ) ; info ! ( " " external_path display ( ) ) ; let mut raw_source = String :: new ( ) ; File :: open ( external_path ) . map_err ( | e | SimpleError :: with ( & format ! ( " \" \" " path ) , e ) ) ? . read_to_string ( & mut raw_source ) . map_err ( | e | SimpleError :: with ( " " , e ) ) ? ; Ok ( raw_source ) }
load source code from internal files or external filesystem depending on the path
load source code from internal files or external filesystem depending on the path
path
String
path
String