-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_open.rs
More file actions
38 lines (32 loc) · 923 Bytes
/
Copy pathbasic_open.rs
File metadata and controls
38 lines (32 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Minimal "hello world" — open a DWG, print its version and section
//! list. Run with:
//!
//! ```bash
//! cargo run --example basic_open -- path/to/file.dwg
//! ```
use dwg::DwgFile;
use std::env;
use std::process::ExitCode;
fn main() -> ExitCode {
let Some(path) = env::args().nth(1) else {
eprintln!("usage: basic_open <file.dwg>");
return ExitCode::FAILURE;
};
let file = match DwgFile::open(&path) {
Ok(f) => f,
Err(e) => {
eprintln!("failed to open {path}: {e}");
return ExitCode::FAILURE;
}
};
println!("file: {path}");
println!("version: {}", file.version());
println!("sections: {}", file.sections().len());
for section in file.sections() {
println!(
" {:<32} {:>10} bytes at 0x{:x}",
section.name, section.size, section.offset
);
}
ExitCode::SUCCESS
}