Clarify that seeked filesystem is not handled by library

This commit is contained in:
Rafał Harabień 2018-05-09 15:34:41 +02:00
parent 3c52f35f6d
commit 429864a69f

View File

@ -224,9 +224,16 @@ pub struct FileSystem<'a> {
impl <'a> FileSystem<'a> { impl <'a> FileSystem<'a> {
/// Creates new filesystem object instance. /// Creates new filesystem object instance.
/// ///
/// Supplied disk parameter cannot be seeked. If there is a need to read a fragment of disk image (e.g. partition)
/// library user should provide a custom implementation of ReadWriteSeek trait.
///
/// Note: creating multiple filesystem objects with one underlying device/disk image can /// Note: creating multiple filesystem objects with one underlying device/disk image can
/// cause filesystem corruption. /// cause filesystem corruption.
pub fn new<T: ReadWriteSeek>(disk: &'a mut T, options: FsOptions) -> io::Result<FileSystem<'a>> { pub fn new<T: ReadWriteSeek>(disk: &'a mut T, options: FsOptions) -> io::Result<FileSystem<'a>> {
// Make sure given image is not seeked
debug_assert!(disk.seek(SeekFrom::Current(0))? == 0);
// Read boot sector
let bpb = { let bpb = {
let boot = BootRecord::deserialize(disk)?; let boot = BootRecord::deserialize(disk)?;
if boot.boot_sig != [0x55, 0xAA] { if boot.boot_sig != [0x55, 0xAA] {