Documentation
¶
Overview ¶
Package backup implements io.Reader and io.Writer and io.Seeker for Microsoft NT Backup File.
Index ¶
Constants ¶
const ( StreamNormalAttribute uint32 = 0 StreamModifiedWhenRead uint32 = 1 << (iota - 1) StreamContainsSecurity StreamContainsProperties StreamSparseAttribute StreamContainsGhostedFileExtents )
Stream attributes indicates properties of the backup stream.
Variables ¶
var ( ErrEmptyADSName = errors.New("alternate data stream should have a name") ErrSkipHeader = errors.New("tried to skip stream header") )
Functions ¶
This section is empty.
Types ¶
type BackupCtx ¶
type BackupCtx struct {
Hdr *BackupHeader
BytesLeft int64 // bytes left in the current data stream
LastErr error // last error from read or write
// contains filtered or unexported fields
}
type BackupFileReader ¶
type BackupFileReader struct {
// contains filtered or unexported fields
}
func NewBackupFileReader ¶
func NewBackupFileReader(path string, processSecurity bool) (*BackupFileReader, error)
func (*BackupFileReader) Close ¶
func (r *BackupFileReader) Close() error
type BackupFileWriter ¶
type BackupFileWriter struct {
// contains filtered or unexported fields
}
func NewBackupFileWriter ¶
func NewBackupFileWriter(path string, processSecurity, overwrite bool) (*BackupFileWriter, error)
func (*BackupFileWriter) Close ¶
func (w *BackupFileWriter) Close() error
type BackupHeader ¶
type BackupHeader struct {
// indicates the type of data in this backup stream
Id StreamType
// indicates properties of the backup stream
Attributes uint32
// the length of the data portion of the backup stream, excluding the length
// of the offset if Id == BackupSparseBlock
Size int64
// if Id == BackupAlternateData, name of alternate data stream, which is the
// part of the actual stored format ":Name:$DATA"
Name string
// if Id == BackupSparseBlock, offset within file stream of the data contained in this sparse block
SparseOffset uint64
// contains filtered or unexported fields
}
BackupHeader represents a header of backup stream of a backup file.
func (*BackupHeader) GetFullSize ¶
func (hdr *BackupHeader) GetFullSize() int
GetFullSize returns the size of the header including extra data.
func (*BackupHeader) IsActive ¶
func (hdr *BackupHeader) IsActive() bool
IsActive returns true if the header is currently active and needs to be handled.
func (*BackupHeader) ToBytes ¶
func (hdr *BackupHeader) ToBytes() ([]byte, error)
ToBytes returns a byte slice which contains [WIN32_STREAM_ID] struct
type BackupUtil ¶
type BackupUtil struct {
// handle data after reading based on the context
//
// if (*BackupHeader).IsActive returns true, the data of
// the header should be handled and passed to the returned
// slice
Handler func(ctx BackupCtx, data []byte) ([]byte, error)
// contains filtered or unexported fields
}
BackupUtil is a wrapper for backing up file with user-defined handler.
func NewBackupUtil ¶
func NewBackupUtil(r io.ReadSeekCloser) *BackupUtil
func (*BackupUtil) Close ¶
func (u *BackupUtil) Close() error
func (*BackupUtil) Seek ¶
func (u *BackupUtil) Seek(offset int64, whence int) (int64, error)
Seek implements io.Seeker.Seek, note that if BackupFileReader is used only io.SeekCurrent can be used for whence due to limitation of w32api.BackupSeek.
type RestoreUtil ¶
type RestoreUtil struct {
// handle data before writing based on the context
//
// if (*BackupHeader).IsActive returns true, the data of
// the header should be handled and passed to the returned
// slice
Handler func(ctx BackupCtx, data []byte) ([]byte, error)
// callback for handling the returned error from the underlying [io.Writer]
//
// if not set explicitly, it just returns the error itself
WriteCb func(err error) error
// contains filtered or unexported fields
}
RestoreUtil is a wrapper for restoring file with user-defined handler.
func NewRestoreUtil ¶
func NewRestoreUtil(w w32api.WriteSeekCloser) *RestoreUtil
func (*RestoreUtil) Close ¶
func (rs *RestoreUtil) Close() error
func (*RestoreUtil) Seek ¶
func (rs *RestoreUtil) Seek(offset int64, whence int) (int64, error)
Seek implements io.Seeker.Seek, note that if BackupFileWriter is used only io.SeekCurrent can be used for whence due to limitation of w32api.BackupSeek.
type StreamType ¶
type StreamType uint32
StreamType indicates the type of data in this backup stream.
Can be used for handling data based on the type.
const ( BackupInvalid StreamType = iota BackupData BackupEaData BackupSecurityData BackupAlternateData BackupLink BackupPropertyData BackupObjectId BackupReparseData BackupSparseBlock BackupTxfsData BackupGhostedFileExtents )