32 lines
553 B
Go
32 lines
553 B
Go
package extract
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
type Extractor struct {
|
|
params *Params
|
|
Clean bool
|
|
}
|
|
|
|
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.Base(params.LogFile), 0755); err != nil {
|
|
panic(err)
|
|
}
|
|
return &Extractor{params: params, Clean: true}
|
|
}
|
|
|
|
func (e *Extractor) Cleanup() error {
|
|
if e.Clean {
|
|
os.RemoveAll(e.params.TempPath)
|
|
}
|
|
return nil
|
|
}
|