Struct libfar::farlib::FarFile [−][src]
Expand description
Struct containing a file, whether or not it’s in an archive. This should be used when creating a file from a buffer, or when getting files from an archive.
Should be created by calling FarFile::new_from_archive
if extracting from an archive, or
FarFile::new_from_file
if reading from a buffer.
Examples
// buffer is a Vec<u8> containing the contents of a file
// fileA_name is the name of the file
use libfar::farlib::FarFile;
let fileA = FarFile::new_from_file(fileA_name, buffer.len() as u32, buffer);
// archive_buf is a Vec<u8> containing the contents of a .far file
// fileB_name is the name of the file that we got from reading the manifest
// fileB_size is the size of the file that we got from reading the manifest
// fileB_offset is the offset of the file that we got from reading the manifest
let fileB = FarFile::new_from_archive(fileB_name, fileB_size, fileB_offset, archive_buf);
Fields
name: String
size: u32
data: Vec<u8>
Implementations
Creates a new FarFile struct from an offset, size, and archive buffer.
Examples
// archive_buf is a Vec<u8> containing the contents of a .far file
// file_name is the name of the file that we got from reading the manifest
// file_size is the size of the file that we got from reading the manifest
// file_offset is the offset of the file that we got from reading the manifest
use libfar::farlib::FarFile;
let file = FarFile::new_from_archive(file_name, file_size, file_offset, archive_buf);
Creates a new FarFile struct from a size, and data buffer.
Examples
// buffer is a Vec<u8> containing the contents of a file
// file_name is the name of the file
use libfar::farlib::FarFile;
let file = FarFile::new_from_file(file_name, buffer.len() as u32, buffer);