macho/macho-go/internal/wrapper/action/write_file.go

33 lines
603 B
Go
Raw Permalink Normal View History

2023-05-31 16:17:03 +07:00
package action
import (
"io/ioutil"
. "ios-wrapper/internal/wrapper/ofile"
"ios-wrapper/pkg/ios/fat"
)
type writeFile struct {
outfile string
}
func (action *writeFile) withMacho(mf *MachoFile) error {
data, _ := ioutil.ReadFile(mf.TmpFile())
return ioutil.WriteFile(action.outfile, data, 0644)
}
func (action *writeFile) withFat(ff *FatFile) error {
var files []string
for _, macho := range ff.Machos() {
files = append(files, macho.TmpFile())
}
fat.FatJoin(files, action.outfile)
return nil
}
func NewWriteFileAction(outfile string) *writeFile {
return &writeFile{
outfile,
}
}