1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Create a CPIO archive from filenames passed through stdin.

use cpio::{NewcBuilder, write_cpio};
use std::fs::File;
use std::io::{self, BufRead, stdin, stdout};

fn load_file(path: &str) -> io::Result<(NewcBuilder, File)> {
	let builder = NewcBuilder::new(path)
		.uid(1000)
		.gid(1000)
		.mode(0o100644);
		
	File::open(path)
		.map(|fp| (builder, fp))
}

fn main() {
	let stdin = stdin();
	let inputs = stdin
		.lock()
		.lines()
		.map(|path| load_file(&path.unwrap()).unwrap());
		
	write_cpio(inputs, stdout()).unwrap();
}