(
obj_path: &std::path::Path,
config: &DiffObjConfig,
diff_side: DiffSide,
)
| 1054 | |
| 1055 | #[cfg(feature = "std")] |
| 1056 | pub fn read( |
| 1057 | obj_path: &std::path::Path, |
| 1058 | config: &DiffObjConfig, |
| 1059 | diff_side: DiffSide, |
| 1060 | ) -> Result<Object> { |
| 1061 | let (data, timestamp) = { |
| 1062 | let file = std::fs::File::open(obj_path)?; |
| 1063 | let timestamp = filetime::FileTime::from_last_modification_time(&file.metadata()?); |
| 1064 | (unsafe { memmap2::Mmap::map(&file) }?, timestamp) |
| 1065 | }; |
| 1066 | let mut obj = parse(&data, config, diff_side)?; |
| 1067 | obj.path = Some(obj_path.to_path_buf()); |
| 1068 | obj.timestamp = Some(timestamp); |
| 1069 | Ok(obj) |
| 1070 | } |
| 1071 | |
| 1072 | pub fn parse(data: &[u8], config: &DiffObjConfig, diff_side: DiffSide) -> Result<Object> { |
| 1073 | let obj_file = object::File::parse(data)?; |
no test coverage detected