package extract import ( "os" "path/filepath" "sync" ) type Extractor struct { params *Params Clean bool mutex sync.RWMutex report *Report } func NewExtractor(params *Params) *Extractor { if err := os.MkdirAll(params.OutputPath, 0755); err != nil { panic(err) } if err := os.MkdirAll(params.TempPath, 0755); err != nil { panic(err) } if err := os.MkdirAll(filepath.Dir(params.LogFile), 0755); err != nil { panic(err) } return &Extractor{params: params, Clean: true, report: &Report{SegmentDirRoot: params.OutputPath}} } func (e *Extractor) Cleanup() error { if e.Clean { os.RemoveAll(e.params.TempPath) } return nil }