poifs

package
v0.0.0-...-327edbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGNATURE              uint64 = 0xE11AB1A1E011CFD0
	SMALLER_BIG_BLOCK_SIZE        = 0x0200

	LARGER_BIG_BLOCK_SIZE = 0x1000

	SMALL_BLOCK_SIZE = 0x0040
	PROPERTY_SIZE    = 0x0080 //How big single property is
	/**
	 * The minimum size of a document before it's stored using
	 *  Big Blocks (normal streams). Smaller documents go in the
	 *  Mini Stream (SBAT / Small Blocks)
	 */
	BIG_BLOCK_MINIMUM_DOCUMENT_SIZE = 0x1000
	/** The highest sector number you're allowed, 0xFFFFFFFA */
	LARGEST_REGULAR_SECTOR_NUMBER = -5

	/** Indicates the sector holds a DIFAT block (0xFFFFFFFC) */
	DIFAT_SECTOR_BLOCK = -4
	/** Indicates the sector holds a FAT block (0xFFFFFFFD) */
	FAT_SECTOR_BLOCK = -3
	/** Indicates the sector is the end of a chain (0xFFFFFFFE) */
	END_OF_CHAIN = -2
	/** Indicates the sector is not used (0xFFFFFFFF) */
	UNUSED_BLOCK = -1
)
View Source
const (
	BYTE_SIZE   = 1
	SHORT_SIZE  = 2
	INT_SIZE    = 4
	LONG_SIZE   = 8
	DOUBLE_SIZE = 8
)
View Source
const (
	PROPERTY_TYPE_OFFSET int = 0x42
	DIRECTORY_TYPE           = 1
	DOCUMENT_TYPE            = 2
	ROOT_TYPE                = 5
)
View Source
const (
	BLOCK_SHIFT = 6

	BLOCK_MASK      = _block_size - 1
	MAX_BLOCK_COUNT = 65535
)

Variables

View Source
var (
	INVALID_FILE_FORMAT = errors.New("Not a valid compound file")
	READ_ERROR          = errors.New("Error reading compound file")
	OOXML_FILE_FORMAT   = errors.New("The supplied data appears to be in the Office 2007+ XML.")
	BLOCK_ERROR         = errors.New("Unable to read Data Block")
	EMPTY_BLOCK_ERROR   = errors.New("Can not return empty data")

	SMALLER_BIG_BLOCK_SIZE_DETAILS = NewBigBlockSize(SMALLER_BIG_BLOCK_SIZE, 9)
	LARGER_BIG_BLOCK_SIZE_DETAILS  = NewBigBlockSize(LARGER_BIG_BLOCK_SIZE, 12)
	/** The first 4 bytes of an OOXML file, used in detection */
	OOXML_FILE_HEADER = [4]byte{0x50, 0x4B, 0x03, 0x04}
)
View Source
var (
	CLOSED_STREAM_ERROR = errors.New("cannot perform requested operation on a closed stream")
)

Functions

func NewSmallDocumentBlock

func NewSmallDocumentBlock(bigBlockSize POIFSBigBlockSize) *smallDocumentBlock

func RawDataBlock

func RawDataBlock(r io.Reader, blocksize int) *rawDataBlock

func RawDataBlockList

func RawDataBlockList(r io.Reader, bigBlockSize POIFSBigBlockSize) (*rawDataBlockList, error)

func SmallDocBlockFromDataBlock

func SmallDocBlockFromDataBlock(bigBlockSize POIFSBigBlockSize, store []BlockWritable, size int) []*smallDocumentBlock

func SmallDocBlockFromRaw

func SmallDocBlockFromRaw(bigBlockSize POIFSBigBlockSize, blocks []ListManagedBlock) []*smallDocumentBlock

func SmallDocumentBlock

func SmallDocumentBlock(bigBlockSize POIFSBigBlockSize, data []byte, index int) *smallDocumentBlock

func SmallDocumentBlockFill

func SmallDocumentBlockFill(bigBlockSize POIFSBigBlockSize, blocks *[]BlockWritable) int

func SmallDocumentBlockList

func SmallDocumentBlockList(blocks []*smallDocumentBlock) (*smallDocumentBlockList, error)

Types

type BATBlock

type BATBlock struct {
	// contains filtered or unexported fields
}

func CreateBATBlock

func CreateBATBlock(bigBlockSize POIFSBigBlockSize, data bytes.Buffer) *BATBlock

func CreateBATBlocks

func CreateBATBlocks(bigBlockSize POIFSBigBlockSize, entries []int) []*BATBlock

func CreateEmptyBATBlock

func CreateEmptyBATBlock(bigBlockSize POIFSBigBlockSize, isXBAT bool) *BATBlock

func CreateXBATBlocks

func CreateXBATBlocks(bigBlockSize POIFSBigBlockSize, entries []int, startBlock int) []*BATBlock

func NewBATBlock

func NewBATBlock(bigBlockSize POIFSBigBlockSize) *BATBlock

Create a single instance initialized with default values

func NewBATBlockWithEntries

func NewBATBlockWithEntries(bigBlockSize POIFSBigBlockSize, entries []int, start_index, end_index int) *BATBlock

Create a single instance initialized (perhaps partially) with entries

func (*BATBlock) GetOutBlockIndex

func (bb *BATBlock) GetOutBlockIndex() int

func (*BATBlock) GetValueAt

func (bb *BATBlock) GetValueAt(offset int) (int, error)

func (*BATBlock) HasFreeSectors

func (bb *BATBlock) HasFreeSectors() bool

func (*BATBlock) SetOurBlockIndex

func (bb *BATBlock) SetOurBlockIndex(index int)

func (*BATBlock) SetValueAt

func (bb *BATBlock) SetValueAt(offset, val int) error

func (*BATBlock) WriteBlocks

func (bb *BATBlock) WriteBlocks(w io.Writer) error

type BATBlockAndIndex

type BATBlockAndIndex struct {
	// contains filtered or unexported fields
}

func GetBATBlockAndIndex

func GetBATBlockAndIndex(offset int, header HeaderBlock, bats []*BATBlock) *BATBlockAndIndex

*

  • Returns the BATBlock that handles the specified offset,
  • and the relative index within it, for the mini stream.
  • The List of BATBlocks must be in sequential order

func GetSBATBlockAndIndex

func GetSBATBlockAndIndex(offset int, header HeaderBlock, bats []*BATBlock) *BATBlockAndIndex

func (*BATBlockAndIndex) GetBlock

func (bi *BATBlockAndIndex) GetBlock() *BATBlock

func (*BATBlockAndIndex) GetIndex

func (bi *BATBlockAndIndex) GetIndex() int

type BATManaged

type BATManaged interface {
	CountBlocks() int
	SetStartBlock(index int)
}

type BlockAllocationTableReader

type BlockAllocationTableReader struct {
	// contains filtered or unexported fields
}

func NewBlockAllocationTableReader

func NewBlockAllocationTableReader(bigBlockSize POIFSBigBlockSize, block_count int, block_array []int,
	xbat_count, xbat_index int, raw_blocklist BlockList) (*BlockAllocationTableReader, error)

func NewBlockAllocationTableReader1

func NewBlockAllocationTableReader1(bigBlockSize POIFSBigBlockSize,
	blocks []ListManagedBlock, raw_blocklist BlockList) (*BlockAllocationTableReader, error)

type BlockAllocationTableWriter

type BlockAllocationTableWriter struct {
	// contains filtered or unexported fields
}

func NewBlockAllocationTableWriter

func NewBlockAllocationTableWriter(bigBlockSize POIFSBigBlockSize) *BlockAllocationTableWriter

func (*BlockAllocationTableWriter) CountBlocks

func (b *BlockAllocationTableWriter) CountBlocks() int

func (*BlockAllocationTableWriter) CreateBlocks

func (b *BlockAllocationTableWriter) CreateBlocks() int

func (*BlockAllocationTableWriter) GetStartBlock

func (b *BlockAllocationTableWriter) GetStartBlock() int

func (*BlockAllocationTableWriter) SetStartBlock

func (b *BlockAllocationTableWriter) SetStartBlock(start_block int)

func (*BlockAllocationTableWriter) WriteBlocks

func (b *BlockAllocationTableWriter) WriteBlocks(stream io.Writer) error

type BlockList

type BlockList interface {
	Zap(index int)
	Remove(index int) (ListManagedBlock, error)
	Fetch(startBlock, headerPropertiesStartBlock int) ([]ListManagedBlock, error)
	SetBAT(bat *BlockAllocationTableReader) error
	BlockCount() int
}

func GetSmallDocumentBlocks

func GetSmallDocumentBlocks(bigBlockSize POIFSBigBlockSize, blockList *rawDataBlockList, root *RootProperty,
	sbatStart int) (BlockList, error)

type BlockWritable

type BlockWritable interface {
	WriteBlocks(w io.Writer) error
}

func NewPropertyBlockArray

func NewPropertyBlockArray(bigBlockSize POIFSBigBlockSize, props []IProperty) []BlockWritable

* Create an array of PropertyBlocks from an array of Property * instances, creating empty Property instances to make up any * shortfall

type ByteField

type ByteField struct {
	// contains filtered or unexported fields
}

func NewByteField

func NewByteField(offset int, value byte, data []byte) (*ByteField, error)

func NewByteFieldFromBytes

func NewByteFieldFromBytes(offset int, data []byte) (*ByteField, error)

func NewByteFieldWithOffset

func NewByteFieldWithOffset(offset int) (*ByteField, error)

func NewByteFieldWithVal

func NewByteFieldWithVal(offset int, value byte) (*ByteField, error)

func (*ByteField) ReadFromBytes

func (f *ByteField) ReadFromBytes(data []byte)

func (*ByteField) Set

func (f *ByteField) Set(val byte, data []byte)

func (*ByteField) String

func (f *ByteField) String() string

func (*ByteField) WriteToBytes

func (f *ByteField) WriteToBytes(data []byte)

type Child

type Child interface {
	GetNextChild() Child
	GetPreviousChild() Child
	SetPreviousChild(child Child)
	SetNextChild(child Child)
}

type ClassID

type ClassID struct {
	// contains filtered or unexported fields
}

func ClassIDFromBytes

func ClassIDFromBytes(src []byte, offset int) ClassID

func ClassIDFromString

func ClassIDFromString(str string) (ClassID, error)

func NewClassID

func NewClassID() ClassID

func (*ClassID) Read

func (cid *ClassID) Read(src []byte, offset int) []byte

func (*ClassID) SetBytes

func (cid *ClassID) SetBytes(bytes []byte)

func (*ClassID) String

func (cid *ClassID) String() string

func (*ClassID) Write

func (cid *ClassID) Write(dst []byte, offset int) error

type Comparator

type Comparator func(p1, p2 IProperty) int

returns negative if p1 < p2 zero if p1 == p2 positive if p1 > p2

type DataInputBlock

type DataInputBlock struct {
	// contains filtered or unexported fields
}

func GetDataInputBlockFromDocumentBlocks

func GetDataInputBlockFromDocumentBlocks(blocks []*DocumentBlock, offset int) *DataInputBlock

func GetDataInputBlockFromSmallBlocks

func GetDataInputBlockFromSmallBlocks(blocks []*smallDocumentBlock, offset int) *DataInputBlock

func NewDataInputBlock

func NewDataInputBlock(data []byte, startOffset int) *DataInputBlock

func (*DataInputBlock) Available

func (d *DataInputBlock) Available() int

func (*DataInputBlock) ReadFully

func (d *DataInputBlock) ReadFully(buf []byte, offset, length int)

func (*DataInputBlock) ReadIntLE

func (d *DataInputBlock) ReadIntLE() int

func (*DataInputBlock) ReadIntLE2

func (d *DataInputBlock) ReadIntLE2(prevBlock *DataInputBlock, prevBlockAvailable int) int

func (*DataInputBlock) ReadUByte

func (d *DataInputBlock) ReadUByte() int

func (*DataInputBlock) ReadUShortLE

func (d *DataInputBlock) ReadUShortLE() int

func (*DataInputBlock) ReadUShortLE2

func (d *DataInputBlock) ReadUShortLE2(prevBlock *DataInputBlock) int

Reads a short which spans the end of prevBlock

type DirectoryEntry

type DirectoryEntry interface {
	Entry
	Entries() []Entry
	IsEmpty() bool
	EntryCount() int
	HasEntry(name string) bool
	Entry(name string) (Entry, error)
	StorageClsId() ClassID
	SetStorageClsId(cid ClassID)
	//CreateDocument(name string, stream []byte) DocumentEntry
	CreateDocument(name string, r io.Reader) DocumentEntry
	CreateDirectory(name string) DirectoryEntry
}

type DirectoryNode

type DirectoryNode struct {
	*EntryNode
	// contains filtered or unexported fields
}

func NewDirectoryNode

func NewDirectoryNode(prop ParentProperty, fs *POIFSFileSystem, parent *DirectoryNode) (*DirectoryNode, error)

func (*DirectoryNode) ChangeName

func (dn *DirectoryNode) ChangeName(oldName, newName string) bool

func (*DirectoryNode) CreateDirectory

func (dn *DirectoryNode) CreateDirectory(name string) DirectoryEntry

func (*DirectoryNode) CreateDocument

func (dn *DirectoryNode) CreateDocument(name string, stream io.Reader) DocumentEntry

func (dn *DirectoryNode) CreateDocument(name string, stream []byte) DocumentEntry {

func (*DirectoryNode) DeleteEntry

func (dn *DirectoryNode) DeleteEntry(entry *EntryNode) bool

func (*DirectoryNode) Entries

func (dn *DirectoryNode) Entries() []Entry

func (*DirectoryNode) Entry

func (dn *DirectoryNode) Entry(name string) (Entry, error)

func (*DirectoryNode) EntryCount

func (dn *DirectoryNode) EntryCount() int

func (*DirectoryNode) GetFileSystem

func (dn *DirectoryNode) GetFileSystem() *POIFSFileSystem

func (*DirectoryNode) GetPath

func (dn *DirectoryNode) GetPath() *POIFSDocumentPath

func (*DirectoryNode) HasEntry

func (dn *DirectoryNode) HasEntry(name string) bool

func (*DirectoryNode) IsDeleteOK

func (dn *DirectoryNode) IsDeleteOK() bool

func (*DirectoryNode) IsDirectory

func (dn *DirectoryNode) IsDirectory() bool

func (*DirectoryNode) IsEmpty

func (dn *DirectoryNode) IsEmpty() bool

func (*DirectoryNode) SetStorageClsId

func (dn *DirectoryNode) SetStorageClsId(cid ClassID)

func (*DirectoryNode) StorageClsId

func (dn *DirectoryNode) StorageClsId() ClassID

type DirectoryProperty

type DirectoryProperty struct {
	*Property
	// contains filtered or unexported fields
}

func NewDirProperty

func NewDirProperty(name string) *DirectoryProperty

func NewDirPropertyFromData

func NewDirPropertyFromData(index int, array []byte, offset int) *DirectoryProperty

func (*DirectoryProperty) AddChild

func (doc *DirectoryProperty) AddChild(prop IProperty) error

func (*DirectoryProperty) ChangeName

func (doc *DirectoryProperty) ChangeName(prop IProperty, newName string) bool

func (*DirectoryProperty) DelChild

func (doc *DirectoryProperty) DelChild(prop IProperty) bool

func (*DirectoryProperty) GetChildren

func (doc *DirectoryProperty) GetChildren() []IProperty

func (*DirectoryProperty) IsDirectory

func (doc *DirectoryProperty) IsDirectory() bool

func (*DirectoryProperty) PreWrite

func (doc *DirectoryProperty) PreWrite()

type DocumentBlock

type DocumentBlock struct {
	// contains filtered or unexported fields
}

func DocumentBlockFromRawBlock

func DocumentBlockFromRawBlock(block *rawDataBlock) (*DocumentBlock, error)

func DocumentBlockFromStream

func DocumentBlockFromStream(r io.Reader, bigBlockSize POIFSBigBlockSize) (db *DocumentBlock, err error)

func DocumentBlockFromStream(data []byte, bigBlockSize POIFSBigBlockSize) (*DocumentBlock, error) {

func (*DocumentBlock) PartiallyRead

func (db *DocumentBlock) PartiallyRead() bool

func (*DocumentBlock) Size

func (db *DocumentBlock) Size() int

func (*DocumentBlock) WriteBlocks

func (db *DocumentBlock) WriteBlocks(w io.Writer) error

func (*DocumentBlock) WriteData

func (db *DocumentBlock) WriteData(w io.Writer) error

type DocumentEntry

type DocumentEntry interface {
	Entry
	GetSize() int
}

type DocumentInputStream

type DocumentInputStream struct {
	// contains filtered or unexported fields
}

func NewDocInputStream

func NewDocInputStream(doc *POIFSDocument) *DocumentInputStream

func NewDocInputStreamFromDocNode

func NewDocInputStreamFromDocNode(doc *DocumentNode) *DocumentInputStream

func NewDocInputStreamFromEntry

func NewDocInputStreamFromEntry(entry DocumentEntry) *DocumentInputStream

func (*DocumentInputStream) Available

func (d *DocumentInputStream) Available() int

func (*DocumentInputStream) Close

func (d *DocumentInputStream) Close()

func (*DocumentInputStream) GetDataInputBlock

func (d *DocumentInputStream) GetDataInputBlock(offset int) *DataInputBlock

func (*DocumentInputStream) Mark

func (d *DocumentInputStream) Mark(ignoreReadLimit int)

func (*DocumentInputStream) Read

func (d *DocumentInputStream) Read(p []byte) (n int, err error)

func (*DocumentInputStream) Reset

func (d *DocumentInputStream) Reset()

type DocumentNode

type DocumentNode struct {
	*EntryNode
	// contains filtered or unexported fields
}

func NewDocumentNode

func NewDocumentNode(prop *DocumentProperty, parent *DirectoryNode) *DocumentNode

func (*DocumentNode) GetDocument

func (dn *DocumentNode) GetDocument() *POIFSDocument

func (*DocumentNode) GetSize

func (dn *DocumentNode) GetSize() int

func (*DocumentNode) IsDeleteOK

func (dn *DocumentNode) IsDeleteOK() bool

func (*DocumentNode) IsDocument

func (dn *DocumentNode) IsDocument() bool

type DocumentProperty

type DocumentProperty struct {
	*Property
	// contains filtered or unexported fields
}

func NewDocProperty

func NewDocProperty(name string, size int) *DocumentProperty

func NewDocPropertyFromData

func NewDocPropertyFromData(index int, array []byte, offset int) *DocumentProperty

func (*DocumentProperty) IsDirectory

func (doc *DocumentProperty) IsDirectory() bool

func (*DocumentProperty) PreWrite

func (doc *DocumentProperty) PreWrite()

func (*DocumentProperty) SetDocument

func (doc *DocumentProperty) SetDocument(d *POIFSDocument)

func (*DocumentProperty) ShouldUseSmallBlocks

func (doc *DocumentProperty) ShouldUseSmallBlocks() bool

type Entry

type Entry interface {
	GetName() string
	IsDirectory() bool
	IsDocument() bool
	Parent() DirectoryEntry
	Delete() bool
	RenameTo(newName string) bool
}

type EntryNode

type EntryNode struct {
	// contains filtered or unexported fields
}

func NewEntryNode

func NewEntryNode(prop IProperty, parent *DirectoryNode) *EntryNode

func (*EntryNode) Delete

func (en *EntryNode) Delete() bool

func (*EntryNode) GetName

func (en *EntryNode) GetName() string

func (*EntryNode) GetProperty

func (en *EntryNode) GetProperty() IProperty

func (*EntryNode) IsDeleteOK

func (en *EntryNode) IsDeleteOK() bool

func (*EntryNode) IsDirectory

func (en *EntryNode) IsDirectory() bool

func (*EntryNode) IsDocument

func (en *EntryNode) IsDocument() bool

func (*EntryNode) IsRoot

func (en *EntryNode) IsRoot() bool

func (*EntryNode) Parent

func (en *EntryNode) Parent() DirectoryEntry

func (*EntryNode) RenameTo

func (en *EntryNode) RenameTo(newName string) bool

type FixedField

type FixedField interface {
	ReadFromBytes(data []byte)
	WriteToBytes(data []byte)
	String() string
}

type HeaderBlock

type HeaderBlock struct {
	// contains filtered or unexported fields
}

func NewHeaderBlock

func NewHeaderBlock(bigBlockSize POIFSBigBlockSize) *HeaderBlock

Create Header Block initialized with default values

func NewHeaderBlockFromReader

func NewHeaderBlockFromReader(r io.Reader) (*HeaderBlock, error)

func (*HeaderBlock) GetBATArray

func (hb *HeaderBlock) GetBATArray() []int

func (*HeaderBlock) GetBATCount

func (hb *HeaderBlock) GetBATCount() int

func (*HeaderBlock) GetBigBlockSize

func (hb *HeaderBlock) GetBigBlockSize() POIFSBigBlockSize

func (*HeaderBlock) GetPropertyStart

func (hb *HeaderBlock) GetPropertyStart() int

func (*HeaderBlock) GetSBATCount

func (hb *HeaderBlock) GetSBATCount() int

func (*HeaderBlock) GetSBATStart

func (hb *HeaderBlock) GetSBATStart() int

return start of small block (MiniFAT) allocation table

func (*HeaderBlock) GetXBATCount

func (hb *HeaderBlock) GetXBATCount() int

func (*HeaderBlock) GetXBATIndex

func (hb *HeaderBlock) GetXBATIndex() int

func (*HeaderBlock) SetBATCount

func (hb *HeaderBlock) SetBATCount(count int)

func (*HeaderBlock) SetPropertyStart

func (hb *HeaderBlock) SetPropertyStart(startBlock int)

func (*HeaderBlock) SetSBATBlockCount

func (hb *HeaderBlock) SetSBATBlockCount(count int)

func (*HeaderBlock) SetSBATStart

func (hb *HeaderBlock) SetSBATStart(startBlock int)

func (*HeaderBlock) SetXBATCount

func (hb *HeaderBlock) SetXBATCount(count int)

func (*HeaderBlock) SetXBATStart

func (hb *HeaderBlock) SetXBATStart(sb int)

func (*HeaderBlock) WriteData

func (hb *HeaderBlock) WriteData(w io.Writer) error

type HeaderBlockWriter

type HeaderBlockWriter struct {
	// contains filtered or unexported fields
}

func NewHeaderBlockWriter

func NewHeaderBlockWriter(bigBlockSize POIFSBigBlockSize) *HeaderBlockWriter

func NewHeaderBlockWriterFromHeaderBlock

func NewHeaderBlockWriterFromHeaderBlock(hb *HeaderBlock) *HeaderBlockWriter

func (*HeaderBlockWriter) SetBATBlocks

func (w *HeaderBlockWriter) SetBATBlocks(blockCount, startBlock int) []*BATBlock

func (*HeaderBlockWriter) SetPropertyStart

func (w *HeaderBlockWriter) SetPropertyStart(startBlock int)

func (*HeaderBlockWriter) SetSBATBlockCount

func (w *HeaderBlockWriter) SetSBATBlockCount(count int)

func (*HeaderBlockWriter) SetSBATStart

func (w *HeaderBlockWriter) SetSBATStart(startBlock int)

func (*HeaderBlockWriter) WriteBlock

func (w *HeaderBlockWriter) WriteBlock(block *bytes.Buffer)

func (*HeaderBlockWriter) WriteBlocks

func (w *HeaderBlockWriter) WriteBlocks(stream io.Writer) error

type IProperty

type IProperty interface {
	Child
	GetSize() int
	SetSize(size int)
	SetNodeColor(nodeColor byte)
	SetPropertyType(propertyType byte)
	SetStartBlock(startBlock int)
	IsDirectory() bool
	GetName() string
	SetName(name string)
	GetPrevChildIndex() int
	GetNextChildIndex() int
	ChildIndex() int
	GetStorageClsid() ClassID
	SetStorageClsid(cid ClassID)
	GetStartBlock() int
	UseSmallBlocks() bool
	SetIndex(index int)
	WriteData(w io.Writer) error
	PreWrite()
	SetChildProperty(child int)
	GetIndex() int
}

type IntegerField

type IntegerField struct {
	// contains filtered or unexported fields
}

func NewIntegerField

func NewIntegerField(offset, value int, data []byte) (*IntegerField, error)

func NewIntegerFieldFromBytes

func NewIntegerFieldFromBytes(offset int, data []byte) (*IntegerField, error)

func NewIntegerFieldWithOffset

func NewIntegerFieldWithOffset(offset int) (*IntegerField, error)

func NewIntegerFieldWithVal

func NewIntegerFieldWithVal(offset, value int) (*IntegerField, error)

func (*IntegerField) ReadFromBytes

func (f *IntegerField) ReadFromBytes(data []byte)

func (*IntegerField) Set

func (f *IntegerField) Set(val int, data []byte)

func (*IntegerField) String

func (f *IntegerField) String() string

func (*IntegerField) WriteToBytes

func (f *IntegerField) WriteToBytes(data []byte)

type Iterator

type Iterator interface {
	HasNext() bool
	Next() interface{}
}

type ListManagedBlock

type ListManagedBlock interface {
	Data() ([]byte, error)
}

type POIFSBigBlockSize

type POIFSBigBlockSize struct {
	BigBlockSize int
	HeaderValue  int16
}

func NewBigBlockSize

func NewBigBlockSize(blocksize int, headval int16) POIFSBigBlockSize

func (POIFSBigBlockSize) BATEntriesPerBlock

func (b POIFSBigBlockSize) BATEntriesPerBlock() int

func (POIFSBigBlockSize) NextXBATChainOffset

func (b POIFSBigBlockSize) NextXBATChainOffset() int

func (POIFSBigBlockSize) PropertiesPerBlock

func (b POIFSBigBlockSize) PropertiesPerBlock() int

func (POIFSBigBlockSize) XBATEntriesPerBlock

func (b POIFSBigBlockSize) XBATEntriesPerBlock() int

type POIFSDocument

type POIFSDocument struct {
	// contains filtered or unexported fields
}

func NewPOIFSDocFromManagedBlock

func NewPOIFSDocFromManagedBlock(name string, bigBlockSize POIFSBigBlockSize, blocks []ListManagedBlock, length int) *POIFSDocument

func NewPOIFSDocFromManagedBlock2

func NewPOIFSDocFromManagedBlock2(name string, blocks []ListManagedBlock, length int) *POIFSDocument

func NewPOIFSDocFromRaw

func NewPOIFSDocFromRaw(name string, blocks []*rawDataBlock, length int) *POIFSDocument

func NewPOIFSDocFromSmallBlocks

func NewPOIFSDocFromSmallBlocks(name string, blocks []*smallDocumentBlock, length int) *POIFSDocument

func NewPOIFSDocFromStream

func NewPOIFSDocFromStream(name string, r io.Reader) (*POIFSDocument, error)

func NewPOIFSDocFromStream(name string, data []byte) (*POIFSDocument, error) {

func NewPOIFSDocFromStream2

func NewPOIFSDocFromStream2(name string, bigBlockSize POIFSBigBlockSize, r io.Reader) (*POIFSDocument, error)

func NewPOIFSDocFromStream2(name string, bigBlockSize POIFSBigBlockSize, data []byte) (*POIFSDocument, error) {

func (*POIFSDocument) CountBlocks

func (d *POIFSDocument) CountBlocks() int

func (*POIFSDocument) GetDataInputBlock

func (d *POIFSDocument) GetDataInputBlock(offset int) *DataInputBlock

func (*POIFSDocument) GetDocumentProperty

func (d *POIFSDocument) GetDocumentProperty() *DocumentProperty

func (*POIFSDocument) GetSmallBlocks

func (d *POIFSDocument) GetSmallBlocks() []BlockWritable

func (*POIFSDocument) SetStartBlock

func (d *POIFSDocument) SetStartBlock(index int)

func (*POIFSDocument) WriteBlocks

func (d *POIFSDocument) WriteBlocks(w io.Writer) error

type POIFSDocumentPath

type POIFSDocumentPath struct {
	// contains filtered or unexported fields
}

func AddPathToPOIFSDocumentPath

func AddPathToPOIFSDocumentPath(path *POIFSDocumentPath, components []string) (*POIFSDocumentPath, error)

func CreatePOIFSDocumentPath

func CreatePOIFSDocumentPath() (*POIFSDocumentPath, error)

func NewPOIFSDocumentPath

func NewPOIFSDocumentPath(components []string) (*POIFSDocumentPath, error)

func (*POIFSDocumentPath) GetComponent

func (dp *POIFSDocumentPath) GetComponent(n int) string

func (*POIFSDocumentPath) GetParent

func (dp *POIFSDocumentPath) GetParent() *POIFSDocumentPath

func (*POIFSDocumentPath) Hashcode

func (dp *POIFSDocumentPath) Hashcode() int

func (*POIFSDocumentPath) Length

func (dp *POIFSDocumentPath) Length() int

func (*POIFSDocumentPath) String

func (dp *POIFSDocumentPath) String() string

type POIFSFileSystem

type POIFSFileSystem struct {
	// contains filtered or unexported fields
}

func FileSystemFromReader

func FileSystemFromReader(r io.Reader) (*POIFSFileSystem, error)

Create Filesystem from Reader. Reader is read until EOF.

func NewFileSystem

func NewFileSystem() *POIFSFileSystem

Create POIFS FileSystem intended for writing

func (*POIFSFileSystem) AddDirectory

func (fs *POIFSFileSystem) AddDirectory(prop ParentProperty)

func (*POIFSFileSystem) AddDocument

func (fs *POIFSFileSystem) AddDocument(doc *POIFSDocument)

func (*POIFSFileSystem) CreateDir

func (fs *POIFSFileSystem) CreateDir(name string) (DirectoryEntry, error)

func (*POIFSFileSystem) CreateDocument

func (fs *POIFSFileSystem) CreateDocument(name string, r io.Reader) (DocumentEntry, error)

func (fs *POIFSFileSystem) CreateDocument(name string, data []byte) (DocumentEntry, error) {

func (*POIFSFileSystem) GetRoot

func (fs *POIFSFileSystem) GetRoot() (*DirectoryNode, error)

func (*POIFSFileSystem) Remove

func (fs *POIFSFileSystem) Remove(entry Entry)

func (*POIFSFileSystem) WriteFileSystem

func (fs *POIFSFileSystem) WriteFileSystem(output io.Writer) error

type Parent

type Parent interface {
	//Child
	AddChild(prop IProperty) error
	DelChild(prop IProperty) bool
	GetChildren() []IProperty
	ChangeName(prop IProperty, newName string) bool
}

type ParentProperty

type ParentProperty interface {
	IProperty
	Parent
}
type ChildProperty interface {
	IProperty
	Child
}

type Property

type Property struct {
	// contains filtered or unexported fields
}

func CreateProperty

func CreateProperty() *Property

func NewProperty

func NewProperty(index int, array []byte, offset int) *Property

func (*Property) ChildIndex

func (p *Property) ChildIndex() int

func (*Property) GetIndex

func (p *Property) GetIndex() int

func (*Property) GetName

func (p *Property) GetName() string

func (*Property) GetNextChild

func (p *Property) GetNextChild() Child

func (*Property) GetNextChildIndex

func (p *Property) GetNextChildIndex() int

func (*Property) GetPrevChildIndex

func (p *Property) GetPrevChildIndex() int

func (*Property) GetPreviousChild

func (p *Property) GetPreviousChild() Child

func (*Property) GetSize

func (p *Property) GetSize() int

func (*Property) GetStartBlock

func (p *Property) GetStartBlock() int

func (*Property) GetStorageClsid

func (p *Property) GetStorageClsid() ClassID

func (*Property) IsDirectory

func (p *Property) IsDirectory() bool

func (*Property) SetChildProperty

func (p *Property) SetChildProperty(child int)

child the child property's index in the Property Table

func (*Property) SetIndex

func (p *Property) SetIndex(index int)

func (*Property) SetName

func (p *Property) SetName(name string)

func (*Property) SetNextChild

func (p *Property) SetNextChild(child Child)

func (*Property) SetNodeColor

func (p *Property) SetNodeColor(nodeColor byte)

func (*Property) SetPreviousChild

func (p *Property) SetPreviousChild(child Child)

func (*Property) SetPropertyType

func (p *Property) SetPropertyType(propertyType byte)

func (*Property) SetSize

func (p *Property) SetSize(size int)

func (*Property) SetStartBlock

func (p *Property) SetStartBlock(startBlock int)

func (*Property) SetStorageClsid

func (p *Property) SetStorageClsid(cid ClassID)

func (*Property) ShortDescription

func (p *Property) ShortDescription() string

func (*Property) UseSmallBlocks

func (p *Property) UseSmallBlocks() bool

func (*Property) WriteData

func (p *Property) WriteData(w io.Writer) error

type PropertyBlock

type PropertyBlock struct {
	// contains filtered or unexported fields
}

func NewPropertyBlock

func NewPropertyBlock(bigBlockSize POIFSBigBlockSize) *PropertyBlock

func (*PropertyBlock) WriteBlocks

func (pb *PropertyBlock) WriteBlocks(w io.Writer) error

type PropertyComparator

type PropertyComparator struct {
	// contains filtered or unexported fields
}

PropertySorter implements the Sort interface, Sorting the changes within

func PropertySorter

func PropertySorter(compare Comparator) *PropertyComparator

returns a Comparator that sorts using the compare function

func (*PropertyComparator) Len

func (pc *PropertyComparator) Len() int

Len is part of sort.Interface.

func (*PropertyComparator) Less

func (pc *PropertyComparator) Less(i, j int) bool

Less is part of sort.Interface.

func (*PropertyComparator) Sort

func (pc *PropertyComparator) Sort(props []IProperty)

Sort sorts the argument slice according to the less functions passed to PropertySorter.

func (*PropertyComparator) Swap

func (pc *PropertyComparator) Swap(i, j int)

Swap is part of sort.Interface.

type PropertyTable

type PropertyTable struct {
	// contains filtered or unexported fields
}

func NewPropertyTable

func NewPropertyTable(hb *HeaderBlock) *PropertyTable

func NewPropertyTableWithList

func NewPropertyTableWithList(hb *HeaderBlock, blocklist *rawDataBlockList) (*PropertyTable, error)

func NewPropertyTableWithProps

func NewPropertyTableWithProps(hb *HeaderBlock, props []IProperty) *PropertyTable

func (*PropertyTable) AddProperty

func (pt *PropertyTable) AddProperty(prop IProperty)

func (*PropertyTable) CountBlocks

func (pt *PropertyTable) CountBlocks() int

func (*PropertyTable) GetRoot

func (pt *PropertyTable) GetRoot() ParentProperty

func (*PropertyTable) GetStartBlock

func (pt *PropertyTable) GetStartBlock() int

func (*PropertyTable) PreWrite

func (pt *PropertyTable) PreWrite()

Prepare to be written

func (*PropertyTable) RemoveProperty

func (pt *PropertyTable) RemoveProperty(prop IProperty)

func (*PropertyTable) SetStartBlock

func (pt *PropertyTable) SetStartBlock(index int)

func (*PropertyTable) WriteBlocks

func (pt *PropertyTable) WriteBlocks(w io.Writer) error

type RootProperty

type RootProperty struct {
	*DirectoryProperty
}

func NewRootProperty

func NewRootProperty() *RootProperty

func NewRootPropertyFromData

func NewRootPropertyFromData(index int, array []byte, offset int) *RootProperty

func (*RootProperty) SetSize

func (p *RootProperty) SetSize(size int)

type ShortField

type ShortField struct {
	// contains filtered or unexported fields
}

func NewShortField

func NewShortField(offset int, value int16, data []byte) (*ShortField, error)

func NewShortFieldFromBytes

func NewShortFieldFromBytes(offset int, data []byte) (*ShortField, error)

func NewShortFieldWithOffset

func NewShortFieldWithOffset(offset int) (*ShortField, error)

func NewShortFieldWithVal

func NewShortFieldWithVal(offset int, value int16) (*ShortField, error)

func (*ShortField) ReadFromBytes

func (f *ShortField) ReadFromBytes(data []byte)

func (*ShortField) Set

func (f *ShortField) Set(val int16, data []byte)

func (*ShortField) String

func (f *ShortField) String() string

func (*ShortField) WriteToBytes

func (f *ShortField) WriteToBytes(data []byte)

type SmallBlockTableWriter

type SmallBlockTableWriter struct {
	// contains filtered or unexported fields
}

func NewSmalBlockTableWriter

func NewSmalBlockTableWriter(bigBlockSize POIFSBigBlockSize, documents []*POIFSDocument,
	root *RootProperty) *SmallBlockTableWriter

func (*SmallBlockTableWriter) CountBlocks

func (s *SmallBlockTableWriter) CountBlocks() int

func (*SmallBlockTableWriter) GetSBAT

func (*SmallBlockTableWriter) GetSBATBlockCount

func (s *SmallBlockTableWriter) GetSBATBlockCount() int

func (*SmallBlockTableWriter) SetStartBlock

func (s *SmallBlockTableWriter) SetStartBlock(start_block int)

func (*SmallBlockTableWriter) WriteBlocks

func (s *SmallBlockTableWriter) WriteBlocks(w io.Writer) error

type Stack

type Stack []interface{}

func (Stack) Cap

func (stack Stack) Cap() int

func (Stack) IsEmpty

func (stack Stack) IsEmpty() bool

func (Stack) Len

func (stack Stack) Len() int

func (*Stack) Pop

func (stack *Stack) Pop() (interface{}, error)

func (*Stack) Push

func (stack *Stack) Push(x interface{})

func (Stack) Top

func (stack Stack) Top() (interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL