Function libxivdat::dat_file::read_content[][src]

pub fn read_content<P: AsRef<Path>>(path: P) -> Result<Vec<u8>, DATError>
Expand description

Attempts to read the entire content block of a DAT file, returning a byte vector. This is a convenience function similar to std::fs::read that automatically handles opening and closing the underlying file.

Errors

If an I/O error occurs while reading the file, a DATError::FileIO error will be returned wrapping the underlying FS error.

A DATError::BadHeader will be returned if the file header cannot be validated, indicating a non-DAT or corrupt file.

A DATError::Overflow is returned if the content would exceed the maximum size specified in the header.

On 16-bit platforms, a DATError::Overflow may be returned if the content is too long to fit into a 16-bit vec. Content length can never exceed u32::MAX, so this error is impossible on other platforms.

Examples

use libxivdat::dat_file::read_content;

let dat_bytes = read_content("./resources/TEST.DAT").unwrap();