fn create_temp_files(&self) -> std::io::Result<TempDir> {
        let temp_dir = TempDir::new("codegen")?;

        fn create_temp_files_helper(dir: &Dir, temp_dir: &TempDir) -> std::io::Result<()> {
            for file in dir.files() {
                let blob_path = file.path();
                let abs_path = temp_dir.path().join(blob_path);

                let mut abs_file = fs::OpenOptions::new()
                    .write(true)
                    .create_new(true)
                    .open(&abs_path)?;
                abs_file.write_all(file.contents())?;

                let mut permissions = abs_file.metadata()?.permissions();
                permissions.set_mode(0o777);
                drop(abs_file);

                // Set permissions of the file so it is executable
                fs::set_permissions(&abs_path, permissions)?;
            }

            for dir in dir.dirs() {
                let blob_path = dir.path();
                let abs_path = temp_dir.path().join(blob_path);
                fs::create_dir(&abs_path)?;

                create_temp_files_helper(dir, temp_dir)?;
            }

            Ok(())
        }
        create_temp_files_helper(&CODEGEN, &temp_dir)?;

        Ok(temp_dir)
    }
/// We bundle all non-Rust, but necessary files into a static CODEGEN blob. When we run the codegen script,
/// we recreate these in a temp directory `/tmp/codegen` that is cleaned up after.
We bundle all non-Rust, but necessary files into a static CODEGEN blob. When we run the codegen script,
we recreate these in a temp directory `/tmp/codegen` that is cleaned up after.
We bundle all non - Rust but necessary files into a static CODEGEN blob . When we run the codegen script we recreate these in a temp directory ` / tmp / codegen ` that is cleaned up after .
fn create_temp_files(&self) -> std::io::Result<TempDir> {
        let temp_dir = TempDir::new("codegen")?;
        fn create_temp_files_helper(dir: &Dir, temp_dir: &TempDir) -> std::io::Result<()> {
            for file in dir.files() {
                let blob_path = file.path();
                let abs_path = temp_dir.path().join(blob_path);
                let mut abs_file = fs::OpenOptions::new()
                    .write(true)
                    .create_new(true)
                    .open(&abs_path)?;
                abs_file.write_all(file.contents())?;
                let mut permissions = abs_file.metadata()?.permissions();
                permissions.set_mode(0o777);
                drop(abs_file);
                // Set permissions of the file so it is executable
                fs::set_permissions(&abs_path, permissions)?;
            }
            for dir in dir.dirs() {
                let blob_path = dir.path();
                let abs_path = temp_dir.path().join(blob_path);
                fs::create_dir(&abs_path)?;
                create_temp_files_helper(dir, temp_dir)?;
            }
            Ok(())
        }
        create_temp_files_helper(&CODEGEN, &temp_dir)?;
        Ok(temp_dir)
    }
fn create_temp_files ( & self ) -> std :: io :: Result < TempDir > { let temp_dir = TempDir :: new ( " " ) ? ; fn create_temp_files_helper ( dir : & Dir , temp_dir : & TempDir ) -> std :: io :: Result < ( ) > { for file in dir . files ( ) { let blob_path = file . path ( ) ; let abs_path = temp_dir . path ( ) . join ( blob_path ) ; let mut abs_file = fs :: OpenOptions :: new ( ) . write ( true ) . create_new ( true ) . open ( & abs_path ) ? ; abs_file . write_all ( file . contents ( ) ) ? ; let mut permissions = abs_file . metadata ( ) ? . permissions ( ) ; permissions . set_mode ( 0o777 ) ; drop ( abs_file ) ; // Set permissions of the file so it is executable fs :: set_permissions ( & abs_path , permissions ) ? ; } for dir in dir . dirs ( ) { let blob_path = dir . path ( ) ; let abs_path = temp_dir . path ( ) . join ( blob_path ) ; fs :: create_dir ( & abs_path ) ? ; create_temp_files_helper ( dir , temp_dir ) ? ; } Ok ( ( ) ) } create_temp_files_helper ( & CODEGEN , & temp_dir ) ? ; Ok ( temp_dir ) }
We bundle all non-Rust, but necessary files into a static CODEGEN blob.
We bundle all non - Rust but necessary files into a static CODEGEN blob .
&self
&self