Documentation ¶
Index ¶
- type DiskStream
- func (s *DiskStream) Close() error
- func (s *DiskStream) EnumerateExtents(f func(*StreamExtent, error) bool)
- func (s *DiskStream) GetDiskType() footer.DiskType
- func (s *DiskStream) GetExtents() ([]*StreamExtent, error)
- func (s *DiskStream) GetSize() int64
- func (s *DiskStream) Read(p []byte) (n int, err error)
- func (s *DiskStream) Seek(offset int64, whence int) (int64, error)
- type StreamExtent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskStream ¶
type DiskStream struct {
// contains filtered or unexported fields
}
DiskStream provides a logical stream over a VHD file. The type exposes the VHD as a fixed VHD, regardless of actual underlying VHD type (dynamic, differencing or fixed type)
func CreateNewDiskStream ¶
func CreateNewDiskStream(vhdPath string) (*DiskStream, error)
CreateNewDiskStream creates a new DiskStream. Parameter vhdPath is the path to VHD
func (*DiskStream) Close ¶
func (s *DiskStream) Close() error
Close closes the VHD file, rendering it unusable for I/O. It returns an error, if any.
Close satisfies io.Closer interface
func (*DiskStream) EnumerateExtents ¶
func (s *DiskStream) EnumerateExtents(f func(*StreamExtent, error) bool)
EnumerateExtents iterate through the extents of the stream that contain non-zero data and invokes the function identified by the parameter f for each extent. Each extent describes a block's data section range which contains data. For dynamic or differencing disk - a block is empty if the BAT corresponding to the block contains 0xFFFFFFFF so returned extents slice will not contain such range. For fixed disk - this method returns extents describing ranges of all blocks, to rule out fixed disk block ranges containing zero bytes use DetectEmptyRanges function in upload package.
func (*DiskStream) GetDiskType ¶
func (s *DiskStream) GetDiskType() footer.DiskType
GetDiskType returns the type of the disk, expected values are DiskTypeFixed, DiskTypeDynamic or DiskTypeDifferencing
func (*DiskStream) GetExtents ¶
func (s *DiskStream) GetExtents() ([]*StreamExtent, error)
GetExtents gets the extents of the stream that contain non-zero data. Each extent describes a block's data section range which contains data. For dynamic or differencing disk - a block is empty if the BAT corresponding to the block contains 0xFFFFFFFF so returned extents slice will not contain such range. For fixed disk - this method returns extents describing ranges of all blocks, to rule out fixed disk block ranges containing zero bytes use DetectEmptyRanges function in upload package.
func (*DiskStream) GetSize ¶
func (s *DiskStream) GetSize() int64
GetSize returns the length of the stream in bytes.
func (*DiskStream) Read ¶
func (s *DiskStream) Read(p []byte) (n int, err error)
Read reads up to len(b) bytes from the Vhd file. It returns the number of bytes read and an error, if any. EOF is signaled when no more data to read and n will set to 0.
If the internal read offset is a byte offset in the data segment of the VHD and If reader reaches end of data section after reading some but not all the bytes then Read won't read from the footer section, the next Read will read from the footer.
If the internal read offset is a byte offset in the footer segment of the VHD and if reader reaches end of footer section after reading some but not all the bytes then Read won't return any error.
Read satisfies io.Reader interface
func (*DiskStream) Seek ¶
func (s *DiskStream) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read on the stream to offset, interpreted according to whence: 0 means relative to the origin of the stream, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.
Seek satisfies io.Seeker interface
type StreamExtent ¶
type StreamExtent struct { Range *common.IndexRange OwnerVhdUniqueID *common.UUID }
StreamExtent describes a block range of a disk which contains data.