comdoc

package
v7.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Microsoft Compound Document File Reference: https://www.openoffice.org/sc/compdocfileformat.pdf ERRATA: The above document says the 0th sector is always 512 bytes into the file. This is not correct. If SectorSize > 512 bytes then the 0th sector is SectorSize bytes into the file.

Index

Constants

View Source
const (
	SecIDFree       SecID = -1
	SecIDEndOfChain SecID = -2
	SecIDSAT        SecID = -3
	SecIDMSAT       SecID = -4

	DirEmpty   DirType = 0
	DirStorage DirType = 1
	DirStream  DirType = 2
	DirRoot    DirType = 5

	Red   Color = 0
	Black Color = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color uint8

type ComDoc

type ComDoc struct {
	File            io.ReaderAt
	Header          *Header
	SectorSize      int
	ShortSectorSize int
	FirstSector     int64
	MSAT, SAT, SSAT []SecID
	Files           []DirEnt
	// contains filtered or unexported fields
}

CDF file open for reading or writing

func ReadFile

func ReadFile(reader io.ReaderAt) (*ComDoc, error)

Parse an already-open CDF file for reading

func ReadPath

func ReadPath(path string) (*ComDoc, error)

Open a CDF file for reading

func WriteFile

func WriteFile(f *os.File) (*ComDoc, error)

Parse an already-open CDF file for reading and writing

func WritePath

func WritePath(path string) (*ComDoc, error)

Open a CDF file for reading and writing

func (*ComDoc) AddFile

func (r *ComDoc) AddFile(name string, contents []byte) error

Add or replace a named stream with the given contents. Only streams within the root storage are currently supported.

func (*ComDoc) Close

func (r *ComDoc) Close() error

Close the CDF and, if open for writing, commit the remainder of structures to disk.

func (*ComDoc) DeleteFile

func (r *ComDoc) DeleteFile(name string) error

Delete a file from the root storage if it exists

func (*ComDoc) ListDir

func (r *ComDoc) ListDir(parent *DirEnt) ([]*DirEnt, error)

List the items in a storage. If parent is nil, the root storage is used.

func (*ComDoc) ReadStream

func (r *ComDoc) ReadStream(e *DirEnt) (io.Reader, error)

Open a stream for reading

func (*ComDoc) RootStorage

func (r *ComDoc) RootStorage() *DirEnt

Return a pointer to the root storage.

type DirEnt

type DirEnt struct {
	RawDirEnt
	// Index into the directory stream holding this entry
	Index int
	// contains filtered or unexported fields
}

Parsed CDF directory entry

func (DirEnt) Name

func (e DirEnt) Name() string

Return the UTF8 name of this entry

type DirType

type DirType uint8
type Header struct {
	Magic            [8]byte
	UID              [16]byte
	Revision         uint16
	Version          uint16
	ByteOrder        uint16
	SectorSize       uint16 // power of 2
	ShortSectorSize  uint16 // power of 2
	Reserved1        [6]byte
	DirSectorCount   uint32 // undocumented?
	SATSectors       uint32
	DirNextSector    SecID
	Reserved2        uint32
	MinStdStreamSize uint32
	SSATNextSector   SecID
	SSATSectorCount  uint32
	MSATNextSector   SecID
	MSATSectorCount  uint32
	MSAT             [msatInHeader]SecID
}

Raw CDF file header

type RawDirEnt

type RawDirEnt struct {
	NameRunes   [32]uint16
	NameLength  uint16
	Type        DirType
	Color       Color
	LeftChild   int32
	RightChild  int32
	StorageRoot int32
	UID         [16]byte
	UserFlags   uint32
	CreateTime  uint64
	ModifyTime  uint64
	NextSector  SecID
	StreamSize  uint32
	// contains filtered or unexported fields
}

Raw CDF directory entry

func (RawDirEnt) Name

func (e RawDirEnt) Name() string

Return the UTF8 name of this entry

type SecID

type SecID int32

Jump to

Keyboard shortcuts

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