Documentation
¶
Overview ¶
Package util common utilities or other elements shared across github.com/herrdivad/go-diskfs packages
Index ¶
- Constants
- func DumpByteSlice(b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool, ...) (out string)
- func DumpByteSlicesWithDiffs(a, b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool) (different bool, out string)
- func Uniqify[T comparable](s []T) []T
- type Bitmap
- func (bm *Bitmap) Clear(location int) error
- func (bm *Bitmap) FirstFree(start int) int
- func (bm *Bitmap) FirstSet() int
- func (bm *Bitmap) FreeList() []Contiguous
- func (bm *Bitmap) FromBytes(b []byte)
- func (bm *Bitmap) IsSet(location int) (bool, error)
- func (bm *Bitmap) Set(location int) error
- func (bm *Bitmap) ToBytes() []byte
- type Contiguous
- type File
Constants ¶
const (
// AppNameVersion name and URL to app
AppNameVersion = "https://github.com/herrdivad/go-diskfs"
)
Variables ¶
This section is empty.
Functions ¶
func DumpByteSlice ¶
func DumpByteSlice(b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool, showOnlyBytes []int) (out string)
DumpByteSlice dump a byte slice in hex and optionally ASCII format. Optionally but position at the beginning of each row, like xxd. Optionally convert to ASCII at end of each row, like xxd. Can show positions at beginning of each row in hex, decimal or both. Can filter out all rows except those containing given positions in showOnlyBytes. If showOnlyBytes is nil, all rows are shown. If showOnlyBytes is not nil, even an empty slice, will only show those rows that contain the given positions.
func DumpByteSlicesWithDiffs ¶
func DumpByteSlicesWithDiffs(a, b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool) (different bool, out string)
DumpByteSlicesWithDiffs show two byte slices in hex and ASCII format, with differences highlighted.
func Uniqify ¶
func Uniqify[T comparable](s []T) []T
Types ¶
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap is a structure holding a bitmap
func BitmapFromBytes ¶
BitmapFromBytes create a bitmap struct from bytes
func NewBitmap ¶
NewBitmap creates a new bitmap of size bytes; it is not in bits to force the caller to have a complete set
func (*Bitmap) FirstFree ¶
FirstFree returns the first free bit in the bitmap Begins at start, so if you want to find the first free bit, pass start=1. Returns -1 if none found.
func (*Bitmap) FreeList ¶
func (bm *Bitmap) FreeList() []Contiguous
FreeList returns a slicelist of contiguous free locations by location. It is sorted by location. If you want to sort it by size, uses sort.Slice for example, if the bitmap is 10010010 00100000 10000010, it will return
1: 2, // 2 free bits at position 1 4: 2, // 2 free bits at position 4 8: 3, // 3 free bits at position 8 11: 5 // 5 free bits at position 11 17: 5 // 5 free bits at position 17 23: 1, // 1 free bit at position 23
if you want it in reverse order, just reverse the slice.
func (*Bitmap) FromBytes ¶
FromBytes overwrite the existing map with the contents of the bytes. It is the equivalent of BitmapFromBytes, but uses an existing Bitmap.
type Contiguous ¶
Contiguous a position and count of contiguous bits, either free or set