Function libxivdat::dat_file::write_content[][src]

pub fn write_content<P: AsRef<Path>>(
    path: P,
    buf: &[u8]
) -> Result<usize, DATError>
Expand description

Attempts to write an input buffer as the content block of a DAT File, replacing the entire existing contents and returning the number of bytes written. This is a convenience function that automatically handles opening and closing the underlying file.

This will only write to an existing DAT file. Use DATFile::create() to create a new DAT 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 or the maximum possible size (u32::MAX).

Examples

use libxivdat::dat_file::write_content;


write_content(&path, b"Who's awesome? You're awesome!").unwrap();