mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 21:31:17 -06:00
Merge remote-tracking branch 'origin/pr/384'
This commit is contained in:
@@ -80,21 +80,16 @@ fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap<PathBuf,
|
||||
fn concat_files(source_paths: Vec<PathBuf>, target_path: PathBuf) -> io::Result<()> {
|
||||
println!("Concatenating into {}:", target_path.to_string_lossy());
|
||||
let mut target = try!(File::create(target_path));
|
||||
let mut is_first = true;
|
||||
try!(target.write_all(b"\n[TOC]\n"));
|
||||
|
||||
for path in source_paths {
|
||||
println!(" {}", path.to_string_lossy());
|
||||
let mut source = try!(File::open(path));
|
||||
let mut contents: Vec<u8> = Vec::new();
|
||||
try!(source.read_to_end(&mut contents));
|
||||
|
||||
if is_first {
|
||||
try!(target.write_all(b"\n[TOC]\n\n"));
|
||||
} else {
|
||||
try!(target.write_all(b"\n"));
|
||||
}
|
||||
try!(target.write_all(b"\n"));
|
||||
try!(target.write_all(&contents));
|
||||
|
||||
is_first = false;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user