pe_assembler/formats/lib/
mod.rs1#![doc = include_str!("readme.md")]
2
3pub mod reader;
4pub mod writer;
5
6use crate::{
7 helpers::CoffReader,
8 types::{CoffFileType, CoffInfo, StaticLibrary},
9};
10use gaia_types::{helpers::open_file, GaiaError};
11pub use reader::LibReader;
12use std::{
13 io::{BufReader, Cursor},
14 path::Path,
15};
16pub use writer::WriteConfig;
17
18#[derive(Copy, Clone, Debug)]
19pub struct LibReadConfig {}
20
21pub fn lib_from_bytes(data: &[u8]) -> Result<StaticLibrary, GaiaError> {
23 let reader = LibReader::new(Cursor::new(data));
24 reader.finish().result
25}
26
27pub fn lib_from_file<P>(path: P) -> Result<StaticLibrary, GaiaError>
28where
29 P: AsRef<Path>,
30{
31 let (file, url) = open_file(path.as_ref())?;
32 let reader = LibReader::new(file).with_url(url);
33 reader.finish().result
34}
35
36pub fn lib_file_type<P: AsRef<Path>>(path: P) -> Result<CoffFileType, GaiaError> {
37 let (file, url) = open_file(path.as_ref())?;
38 let mut reader = LibReader::new(BufReader::new(file)).with_url(url);
39 reader.get_coff_header()?;
40 todo!()
41}
42
43pub fn lib_file_info<P: AsRef<Path>>(path: P) -> Result<CoffInfo, GaiaError> {
45 let (file, url) = open_file(path.as_ref())?;
46 let mut reader = LibReader::new(BufReader::new(file)).with_url(url);
47 reader.get_coff_header()?;
48 todo!()
49}