Documentation ¶
Index ¶
Constants ¶
View Source
const ( HEADER_LEN int = 512 // length of CFB file header, in bytes DIR_ENTRY_LEN int = 128 // length of directory entry, in bytes NUM_DIFAT_ENTRIES_IN_HEADER int = 109 )
View Source
const ( MINOR_VERSION int = 0x3e BYTE_ORDER_MARK uint16 = 0xfffe MINI_SECTOR_SHIFT uint16 = 6 // 64-byte mini sectors MINI_SECTOR_LEN int = 1 << (MINI_SECTOR_SHIFT) MINI_STREAM_CUTOFF uint32 = 4096 )
View Source
const ( MAX_REGULAR_SECTOR uint32 = 0xfffffffa INVALID_SECTOR uint32 = 0xfffffffb DIFAT_SECTOR uint32 = 0xfffffffc FAT_SECTOR uint32 = 0xfffffffd END_OF_CHAIN uint32 = 0xfffffffe FREE_SECTOR uint32 = 0xffffffff )
Constants for FAT entries:
View Source
const ( ROOT_DIR_NAME = "Root Entry" OBJ_TYPE_UNALLOCATED uint8 = 0 OBJ_TYPE_STORAGE uint8 = 1 OBJ_TYPE_STREAM uint8 = 2 OBJ_TYPE_ROOT uint8 = 5 COLOR_RED uint8 = 0 COLOR_BLACK uint8 = 1 ROOT_STREAM_ID uint32 = 0 MAX_REGULAR_STREAM_ID uint32 = 0xfffffffa NO_STREAM uint32 = 0xffffffff )
Constants for directory entries:
View Source
const MAX_NAME_LEN int = 31
Variables ¶
View Source
var (
ErrorInvalidCFB = errors.New("invalid cfb file")
)
View Source
var MAGIC_NUMBER = []byte{0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1}
Constants for CFB file header values:
Functions ¶
func ValidateName ¶
Types ¶
type Allocator ¶
type Allocator struct { Sector *Sector DifatSectorIds []uint32 Difat []uint32 Fat []uint32 Validation Validation }
func NewAllocator ¶
func (*Allocator) SeekWithinSector ¶
type Chain ¶
type Chain struct { Allocator *Allocator SectorInit SectorInit SectorIds []uint32 OffsetFromStart uint64 }
func NewChain ¶
func NewChain(allocator *Allocator, startingSectorId uint32, init SectorInit) (*Chain, error)
func (*Chain) NumSectors ¶
type CompoundFile ¶
type CompoundFile struct { Header *Header Directory *Directory MiniAlloc *MiniAlloc // contains filtered or unexported fields }
func Open ¶
func Open(reader io.ReadSeeker, validation Validation) (*CompoundFile, error)
type DirEntry ¶
type DirEntry struct { Name string ObjType ObjectType Color Color LeftSibling uint32 RightSibling uint32 Child uint32 CLSID [16]byte StateBits uint32 CreationTime uint64 ModifiedTime uint64 StartingSector uint32 StreamSize uint64 }
func NewDirEntry ¶
func NewDirEntry(name string, objType ObjectType, timestamp uint64) *DirEntry
func ReadDirEntry ¶
func ReadDirEntry(reader io.ReadSeeker, version Version, validation Validation) (*DirEntry, error)
type MiniAlloc ¶
func NewMiniAlloc ¶
type ObjectType ¶
type ObjectType int
const ( Unallocated ObjectType = iota Storage Stream Root )
func ObjectFromByte ¶
func ObjectFromByte(b byte) ObjectType
func (ObjectType) AsByte ¶
func (o ObjectType) AsByte() byte
type SectorInit ¶
type SectorInit int
const ( SectorInitZero SectorInit = iota SectorInitFat SectorInitDifat SectorInitDir )
func (SectorInit) Initialize ¶
func (s SectorInit) Initialize(sector *Sector)
type Validation ¶
type Validation int
const ( ValidationPermissive Validation = iota ValidationStrict Validation = iota )
func (Validation) IsStrict ¶
func (v Validation) IsStrict() bool
type Version ¶
type Version int
func VersionNumber ¶
func (Version) DirEntriesPerSector ¶
Returns the number of directory entries per sector in this version.
func (Version) SectorLenMask ¶
Returns the bitmask used for reading stream lengths in this version.
func (Version) SectorShift ¶
Returns the sector shift used in this version.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.