From b530e465f3be5a7909adc1b1a73563501d758e9b Mon Sep 17 00:00:00 2001 From: Luc Street Date: Mon, 2 Jan 2017 22:44:45 -0800 Subject: [PATCH] Tighten up concatenation function a bit --- tools/src/bin/concat_chapters.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/src/bin/concat_chapters.rs b/tools/src/bin/concat_chapters.rs index 94a4e422d..bdccb34f8 100644 --- a/tools/src/bin/concat_chapters.rs +++ b/tools/src/bin/concat_chapters.rs @@ -80,21 +80,16 @@ fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap, 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 = 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(()) }