forked from mirrors/gecko-dev
Differential Revision: https://phabricator.services.mozilla.com/D39454 --HG-- rename : third_party/rust/memmap-0.5.2/LICENSE-APACHE => third_party/rust/memmap-0.6.2/LICENSE-APACHE rename : third_party/rust/memmap-0.5.2/LICENSE-MIT => third_party/rust/memmap-0.6.2/LICENSE-MIT rename : third_party/rust/memmap-0.5.2/ci/install.sh => third_party/rust/memmap-0.6.2/ci/install.sh rename : third_party/rust/fs2/LICENSE-APACHE => third_party/rust/miow-0.2.1/LICENSE-APACHE rename : third_party/rust/memmap-0.5.2/LICENSE-MIT => third_party/rust/miow-0.2.1/LICENSE-MIT rename : third_party/rust/fs2/LICENSE-APACHE => third_party/rust/socket2/LICENSE-APACHE rename : third_party/rust/memmap-0.5.2/LICENSE-MIT => third_party/rust/socket2/LICENSE-MIT rename : third_party/rust/fs2/LICENSE-APACHE => third_party/rust/tokio-named-pipes/LICENSE-APACHE rename : third_party/rust/memmap-0.5.2/LICENSE-MIT => third_party/rust/tokio-named-pipes/LICENSE-MIT extra : moz-landing-system : lando
23 lines
580 B
Rust
23 lines
580 B
Rust
extern crate memmap;
|
|
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::io::{self, Write};
|
|
|
|
use memmap::Mmap;
|
|
|
|
/// Output a file's contents to stdout. The file path must be provided as the first process
|
|
/// argument.
|
|
fn main() {
|
|
let path = env::args()
|
|
.nth(1)
|
|
.expect("supply a single path as the program argument");
|
|
|
|
let file = File::open(path).expect("failed to open the file");
|
|
|
|
let mmap = unsafe { Mmap::map(&file).expect("failed to map the file") };
|
|
|
|
io::stdout()
|
|
.write_all(&mmap[..])
|
|
.expect("failed to output the file contents");
|
|
}
|