Files
sjy01-preprocessing/extract/process.go
nuknal 2b8d4f933d .
2024-10-11 11:25:16 +08:00

36 lines
650 B
Go

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
}