diff --git a/examples/changelog.md b/changelog.md similarity index 100% rename from examples/changelog.md rename to changelog.md diff --git a/examples/map_roundtrip.rs b/examples/map_roundtrip.rs new file mode 100644 index 0000000..c35893d --- /dev/null +++ b/examples/map_roundtrip.rs @@ -0,0 +1,32 @@ +#[cfg(feature = "std")] +fn main() { + use quake_util::qmap; + use std::env::args; + use std::io; + + let mut arguments = args(); + arguments.next(); + + let inpath = if let Some(path) = arguments.next() { + path + } else { + panic!("No input path"); + }; + + let outpath = if let Some(path) = arguments.next() { + path + } else { + panic!("No output path"); + }; + + let infile = std::fs::File::open(inpath).unwrap(); + let mut reader = io::BufReader::new(infile); + let map = qmap::parse(&mut reader).unwrap(); + + let outfile = std::fs::File::create(outpath).unwrap(); + let mut writer = io::BufWriter::new(outfile); + map.write_to(&mut writer).unwrap(); +} + +#[cfg(not(feature = "std"))] +fn main() {}