github.com/shakinm/xlsReader@v0.9.12/cfb/directory.go (about)

     1  package cfb
     2  
     3  import (
     4  	"encoding/binary"
     5  	"unicode/utf16"
     6  	"github.com/shakinm/xlsReader/helpers"
     7  )
     8  
     9  
    10  // Directory - Compound File Directory Entry
    11  type Directory struct {
    12  	DirectoryEntryName       [64]byte
    13  	DirectoryEntryNameLength [2]byte
    14  	ObjectType               byte
    15  	ColorFlag                [1]byte
    16  	LeftSiblingID            [4]byte
    17  	RightSiblingID           [4]byte
    18  	ChildID                  [4]byte
    19  	CLSID                    [16]byte
    20  	StateBits                [4]byte
    21  	CreationTime             [8]byte
    22  	ModifiedTime             [8]byte
    23  	StartingSectorLocation   [4]byte
    24  	StreamSize               [8]byte
    25  }
    26  
    27  //Name - Directory Name
    28  func (d *Directory) Name() string {
    29  
    30  	size := binary.LittleEndian.Uint16(d.DirectoryEntryNameLength[:])
    31  	if size > 0 {
    32  		size=size - 1
    33  	}
    34  	name := helpers.BytesToUints16(d.DirectoryEntryName[:size])
    35  	runes := utf16.Decode(name)
    36  	return string(runes)
    37  }
    38  
    39  //GetStartingSectorLocation - The start sector of the object
    40  func (d *Directory) GetStartingSectorLocation() uint32 {
    41  
    42  	return helpers.BytesToUint32(d.StartingSectorLocation[:])
    43  }
    44  
    45  //GetStreamSize - Object size
    46  func (d *Directory) GetStreamSize() uint32 {
    47  
    48  	return helpers.BytesToUint32(d.StreamSize[:])
    49  }
    50