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 )
type Color uint8
CDF file open for reading or writing
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 }
func ReadFile(reader io.ReaderAt) (*ComDoc, error)
Parse an already-open CDF file for reading
func ReadPath(path string) (*ComDoc, error)
Open a CDF file for reading
func WriteFile(f *os.File) (*ComDoc, error)
Parse an already-open CDF file for reading and writing
func WritePath(path string) (*ComDoc, error)
Open a CDF file for reading and writing
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 (r *ComDoc) Close() error
Close the CDF and, if open for writing, commit the remainder of structures to disk.
func (r *ComDoc) DeleteFile(name string) error
Delete a file from the root storage if it exists
func (r *ComDoc) ListDir(parent *DirEnt) ([]*DirEnt, error)
List the items in a storage. If parent is nil, the root storage is used.
func (r *ComDoc) ReadStream(e *DirEnt) (io.Reader, error)
Open a stream for reading
func (r *ComDoc) RootStorage() *DirEnt
Return a pointer to the root storage.
Parsed CDF directory entry
type DirEnt struct { RawDirEnt // Index into the directory stream holding this entry Index int // contains filtered or unexported fields }
func (e DirEnt) Name() string
Return the UTF8 name of this entry
type DirType uint8
Raw CDF file header
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 directory entry
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 }
func (e RawDirEnt) Name() string
Return the UTF8 name of this entry
type SecID int32