You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
923 B
Go

package commands
import (
"io"
"os"
"git.cheetah.cat/cheetah/moto-flash-data/motolol/cpe"
)
type DecryptDBFCommand struct {
SourceFileName string `long:"src" alias:"i" required:"true" description:"input-filename"`
DestFileName string `long:"dest" alias:"o" required:"true" description:"output-filename"`
}
func (command *DecryptDBFCommand) Execute(args []string) error {
inputFile, err := os.Open(command.SourceFileName)
if err != nil {
return err
}
defer inputFile.Close()
outputFile, err := os.Create(command.DestFileName)
if err != nil {
return err
}
defer outputFile.Close()
inputFileStat, err := inputFile.Stat()
if err != nil {
return err
}
pdata := make([]byte, inputFileStat.Size())
_, err = io.ReadFull(inputFile, pdata)
if err != nil {
return err
}
decrypted := cpe.DecryptDBFFile(pdata)
_, err = outputFile.Write(decrypted)
if err != nil {
return err
}
return nil
}