diff --git a/maraiah/file.rs b/maraiah/file.rs index d9ee3f0..c6552fb 100644 --- a/maraiah/file.rs +++ b/maraiah/file.rs @@ -1,8 +1,7 @@ //! File utilities. -use crate::err::*; -use std::fs; -use std::io::{SeekFrom, prelude::*}; +use crate::{err::*, machdr}; +use std::{fs, path::Path, io::{SeekFrom, prelude::*}}; /// Confirms that the path `p` is a folder. pub fn validate_folder_path(p: &str) -> ResultS<()> @@ -15,6 +14,16 @@ pub fn validate_folder_path(p: &str) -> ResultS<()> } } +/// Opens the file at `path` and skips past any macintosh headers. +pub fn open_mac_file>(path: P) -> ResultS +{ + let mut fp = fs::File::open(path)?; + + machdr::skip_mac_header(&mut fp); + + Ok(fp) +} + impl Drop for SeekBackToStart where T: Seek {