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

34 lines
611 B
Go
Raw Permalink Normal View History

2023-05-31 16:17:03 +07:00
package action
import (
. "ios-wrapper/internal/wrapper/ofile"
)
// Actions on MachoFile
type Action interface {
withMacho(mf *MachoFile) error
withFat(ff *FatFile) error
// TODO: error context
}
func RunAction(action Action, ofile OFile) error {
switch ofile.(type) {
case *MachoFile:
return action.withMacho(ofile.(*MachoFile))
case *FatFile:
return action.withFat(ofile.(*FatFile))
}
// not likely
return nil
}
func defaultWithFat(action Action, ff *FatFile) error {
for _, macho := range ff.Machos() {
err := action.withMacho(macho)
if err != nil {
return err
}
}
return nil
}