Function libxivdat::section::read_section_content_unsafe [−][src]
pub fn read_section_content_unsafe<P: AsRef<Path>>(
path: P
) -> Result<Vec<Section>, DATError>
Expand description
Reads all Sections
from a specified DAT file, returning a Vec
of them.
This performs only one read operation on the underlying file, loading the entire content into memory
to prevent repeat file access. This is similar to read_content()
,
but returns a Vec<Section>
instead of raw bytes. This does not check that the
file is of a type that should contain sections.
Errors
Returns a DATError::Overflow
or
DATError::Underflow
if a section content block
does not match the expected length specified in the section header.
Returns a DATError::BadEncoding
if a section does not
contain valid utf8 text.
Returns a DATError::BadHeader
if the specified file does not
have a valid DAT header.
If an I/O error occurs while reading the file, a DATError::FileIO
error will be returned wrapping the underlying FS error.
Examples
use libxivdat::section::read_section_content_unsafe; let section = read_section_content_unsafe("./resources/TEST_SECTION.DAT").unwrap(); assert_eq!(section[0].tag, "T"); assert_eq!(section[0].content_size, 24); assert_eq!(section[0].content, "This is a test section."); assert_eq!(section[1].tag, "A"); assert_eq!(section[1].content_size, 22); assert_eq!(section[1].content, "Another test section.");