cab

package module
v0.0.0-...-f208e5c Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 8 Imported by: 0

README

Golang Cabinet File Parser

This package provides a simple parser for Microsoft Cabinet (.cab) files, written in Golang.

Example

package main

import (
	"io"
	"os"
	
	"github.com/secDre4mer/go-cab"
)

func main() {
	file, _ := os.Open("path/to/cabfile.cab")
	defer file.Close()
	info, _ := file.Stat()
	
	cabinetFile, _ := cab.Open(file, info.Size())

	for _, file := range cabinetFile.Files {
		reader, _ := file.Open()
		_, _ = io.Copy(os.Stdout, reader)
	}
}

For simplicity's sake, error handling is omitted in this example.

Limitations

  • Cabinet that span multiple files are not supported

Documentation

Index

Constants

View Source
const (
	AttributeReadOnly = 0x1
	AttributeHidden   = 0x2
	AttributeSystem   = 0x4
	AttributeArch     = 0x20
	AttributeExec     = 0x40
	AttributeNameUtf  = 0x80
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cabinet

type Cabinet struct {
	Files               []*File
	ReservedHeaderBlock []byte
	MultiCabinetInfo
}

func Open

func Open(reader io.ReaderAt, size int64) (*Cabinet, error)

type File

type File struct {
	Name       string
	Modified   time.Time
	Attributes uint16
	// contains filtered or unexported fields
}

func (*File) Open

func (f *File) Open() (io.Reader, error)

func (*File) Stat

func (f *File) Stat() fs.FileInfo

type FileInfo

type FileInfo struct {
	File *File
}

func (FileInfo) IsDir

func (f FileInfo) IsDir() bool

func (FileInfo) ModTime

func (f FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (f FileInfo) Mode() fs.FileMode

func (FileInfo) Name

func (f FileInfo) Name() string

func (FileInfo) Size

func (f FileInfo) Size() int64

func (FileInfo) Sys

func (f FileInfo) Sys() any

type MultiCabinetInfo

type MultiCabinetInfo struct {
	PreviousFile string
	PreviousDisk string
	NextFile     string
	NextDisk     string
	SetId        uint16 // ID of this multi-cabinet set; should be the same in all files in the set
	SetIndex     uint16 // Index of this cabinet in the multi-cabinet set
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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