6MN2P2F4ODEDBP26GXQQPBA2YALQFWRMKS6SO4D66NVG2ZREXWVQC
ARH25AEGJAHB7MKAG7UGIQ7U7SX5PATBJ7TEHCPBCCPO7IULHQ2AC
E6XZL3PV6CDCBQKQF5ZINZIOPAN5XJUXSSWQ7BTQ2WAVNAHXQMVQC
MJB2OH2Y5WLKBHNOS37KZELEVIPR46NOWYF74W4E4IA4QPTUGZZQC
use std::fs::File;
let file = File::open(args.udf_image).expect("Failed to open UDF file");
udfread::UdfRead::open_file(&args.udf_image).expect("Failed to create UDF reader");
udfread::UdfRead::open_reader(&file).expect("Failed to create UDF reader");
use std::marker::PhantomData;
struct FileReader {
struct InputAdapter<R: Read + Seek> {
file: File,
reader: R,
impl FileReader { fn new(path: impl AsRef<Path>) -> std::io::Result<*mut c_includes::udfread_block_input> { let file = File::open(path)?;
impl FileReader {
fn new(path: impl AsRef<Path>) -> std::io::Result<*mut c_includes::udfread_block_input> {
let file = File::open(path)?;
impl<R: Read + Seek> InputAdapter<R> { fn new(reader: R) -> *mut c_includes::udfread_block_input {
impl<R: Read + Seek> InputAdapter<R> {
fn new(reader: R) -> *mut c_includes::udfread_block_input {
Ok(Box::into_raw(Box::<Self>::new(Self { funcs, file })) as *mut c_includes::udfread_block_input)
Ok(Box::into_raw(Box::<Self>::new(Self { funcs, file }))
as *mut c_includes::udfread_block_input)
Box::into_raw(Box::<Self>::new(Self { funcs, reader })) as *mut c_includes::udfread_block_input
Box::into_raw(Box::<Self>::new(Self { funcs, reader }))
as *mut c_includes::udfread_block_input
self.file
self.reader
self.file.seek(SeekFrom::Start(byte_offset))?;
self.reader.seek(SeekFrom::Start(byte_offset))?;
let bytes_read = self.file.read(buffer)?;
let bytes_read = self.reader.read(buffer)?;
pub struct UdfRead {
pub struct UdfRead<R: Read + Seek = File> {
phantom: PhantomData<InputAdapter<R>>,
impl UdfRead { pub fn open_file(path: impl AsRef<Path>) -> Option<UdfRead> { let file_reader = match FileReader::new(path) {
impl UdfRead {
pub fn open_file(path: impl AsRef<Path>) -> Option<UdfRead> {
let file_reader = match FileReader::new(path) {
impl UdfRead<File> { pub fn open_file(path: impl AsRef<Path>) -> Option<Self> { let file = match File::open(path) {
impl UdfRead<File> {
pub fn open_file(path: impl AsRef<Path>) -> Option<Self> {
let file = match File::open(path) {
Self::open_reader(file) }}
Self::open_reader(file)
}
impl<R: Read + Seek> UdfRead<R> { pub fn open_reader(reader: R) -> Option<UdfRead<R>> { let input_adapter = InputAdapter::new(reader);
impl<R: Read + Seek> UdfRead<R> {
pub fn open_reader(reader: R) -> Option<UdfRead<R>> {
let input_adapter = InputAdapter::new(reader);
let open_result = unsafe { c_includes::udfread_open_input(udfread, file_reader) };
let open_result = unsafe { c_includes::udfread_open_input(udfread, input_adapter) };
Some(UdfRead { udfread })
Some(UdfRead { udfread, phantom: PhantomData, })
Some(UdfRead {
udfread,
phantom: PhantomData,
})
impl Drop for UdfRead {
impl<R: Read + Seek> Drop for UdfRead<R> {