pub fn process_config_files(&self, outdir: &PathBuf) -> Option<()> {
        if self.datadir.exists() {
            let gresource_id = &self.metadata.id.replace(".", "/");

            let mut variables = HashMap::new();
            variables.insert("@APP_ID@", &self.metadata.id);
            variables.insert("@APP_BINARY@", &self.metadata.bin);
            variables.insert("@APP_NAME@", &self.metadata.name);
            variables.insert("@APP_VERSION@", &self.metadata.version);
            variables.insert("@GRESOURCE_ID@", &gresource_id);
            variables.insert("@GETTEXT_DOMAIN@", &self.metadata.bin);

            std::fs::create_dir_all(&outdir).ok()?;

            for file in std::fs::read_dir(&self.datadir).ok()? {
                let path = file.ok()?.path();
                if path.extension() == Some(OsStr::new("in")) {
                    let mut data = std::fs::read_to_string(&path).ok()?;
                    for (key, value) in variables.iter() {
                        data = data.replace(key, &value);
                    }
                    let output = outdir.join(&path.file_stem()?);
                    std::fs::write(&output.as_path(), data).unwrap();
                } else if path.is_file() {
                    std::fs::copy(&path, outdir.join(&path.file_name()?)).ok()?;
                }
            }
        }

        Some(())
    }
// Detect all .in files in data folder
// and fill data in templates then move
// to target/{debug/release}/data directory
// If file isn't .in move it as it is.
Detect all .in files in data folder
and fill data in templates then move
to target/{debug/release}/data directory
If file isn't .in move it as it is.
Detect all . in files in data folder and fill data in templates then move to target / { debug / release } / data directory If file isn ' t . in move it as it is .
pub fn process_config_files(&self, outdir: &PathBuf) -> Option<()> {
        if self.datadir.exists() {
            let gresource_id = &self.metadata.id.replace(".", "/");
            let mut variables = HashMap::new();
            variables.insert("@APP_ID@", &self.metadata.id);
            variables.insert("@APP_BINARY@", &self.metadata.bin);
            variables.insert("@APP_NAME@", &self.metadata.name);
            variables.insert("@APP_VERSION@", &self.metadata.version);
            variables.insert("@GRESOURCE_ID@", &gresource_id);
            variables.insert("@GETTEXT_DOMAIN@", &self.metadata.bin);
            std::fs::create_dir_all(&outdir).ok()?;
            for file in std::fs::read_dir(&self.datadir).ok()? {
                let path = file.ok()?.path();
                if path.extension() == Some(OsStr::new("in")) {
                    let mut data = std::fs::read_to_string(&path).ok()?;
                    for (key, value) in variables.iter() {
                        data = data.replace(key, &value);
                    }
                    let output = outdir.join(&path.file_stem()?);
                    std::fs::write(&output.as_path(), data).unwrap();
                } else if path.is_file() {
                    std::fs::copy(&path, outdir.join(&path.file_name()?)).ok()?;
                }
            }
        }
        Some(())
    }
pub fn process_config_files ( & self , outdir : & PathBuf ) -> Option < ( ) > { if self . datadir . exists ( ) { let gresource_id = & self . metadata . id . replace ( " " , " " ) ; let mut variables = HashMap :: new ( ) ; variables . insert ( " " , & self . metadata . id ) ; variables . insert ( " " , & self . metadata . bin ) ; variables . insert ( " " , & self . metadata . name ) ; variables . insert ( " " , & self . metadata . version ) ; variables . insert ( " " , & gresource_id ) ; variables . insert ( " " , & self . metadata . bin ) ; std :: fs :: create_dir_all ( & outdir ) . ok ( ) ? ; for file in std :: fs :: read_dir ( & self . datadir ) . ok ( ) ? { let path = file . ok ( ) ? . path ( ) ; if path . extension ( ) == Some ( OsStr :: new ( " " ) ) { let mut data = std :: fs :: read_to_string ( & path ) . ok ( ) ? ; for ( key , value ) in variables . iter ( ) { data = data . replace ( key , & value ) ; } let output = outdir . join ( & path . file_stem ( ) ? ) ; std :: fs :: write ( & output . as_path ( ) , data ) . unwrap ( ) ; } else if path . is_file ( ) { std :: fs :: copy ( & path , outdir . join ( & path . file_name ( ) ? ) ) . ok ( ) ? ; } } } Some ( ( ) ) }
Detect all .in files in data folder
and fill data in templates then move
to target/{debug/release}/data directory
If file isn't .in move it as it is.
Detect all . in files in data folder and fill data in templates then move to target / { debug / release } / data directory If file isn ' t . in move it as it is .
&self
outdir
&PathBuf
&self
outdir
&PathBuf