From 884baebe2d14a1326998be7704beb42564d1e9fd Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 16 Oct 2017 21:09:25 -0700 Subject: SLEEP read helper --- src/bin/geniza-sleep.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bin/geniza-sleep.rs b/src/bin/geniza-sleep.rs index 168f803..b7bb88e 100644 --- a/src/bin/geniza-sleep.rs +++ b/src/bin/geniza-sleep.rs @@ -23,6 +23,9 @@ fn run() -> Result<()> { .arg_from_usage(" 'Magic word to use (eg, 0x5025700)'") .arg_from_usage(" 'Size of each entry (bytes)'") .arg_from_usage(" 'Name of algorithm (empty string for none)'")) + .subcommand(SubCommand::with_name("read-all") + .about("Reads a SLEEP file, iterates through all entries, prints raw bytes") + .arg_from_usage(" 'SLEEP file to read'")) .get_matches(); @@ -51,6 +54,13 @@ fn run() -> Result<()> { algo_name)?; println!("Done!"); }, + ("read-all", Some(subm)) => { + let path = Path::new(subm.value_of("FILE").unwrap()); + let mut sf = SleepFile::open(path, false)?; + for i in 0..sf.length()? { + println!("{}: {:?}", i, sf.read(i)); + } + }, _ => { println!("Missing or unimplemented command!"); println!("{}", matches.usage()); -- cgit v1.2.3