add force lowercase mode for export

This commit is contained in:
Alex Yatskov 2018-12-15 18:30:32 -08:00
parent 9e931a409a
commit d136631eb7

View File

@ -6,6 +6,7 @@ import (
"io"
"os"
"path"
"strings"
"github.com/FooSoft/lazarus/formats/mpq"
"github.com/bmatcuk/doublestar"
@ -37,7 +38,7 @@ func list(mpqPath, filter string) error {
return nil
}
func extract(mpqPath, filter, targetDir string) error {
func extract(mpqPath, filter, targetDir string, lowercase bool) error {
arch, err := mpq.New(mpqPath)
if err != nil {
return err
@ -67,7 +68,7 @@ func extract(mpqPath, filter, targetDir string) error {
}
defer resFile.Close()
sysPath := path.Join(targetDir, resPath)
sysPath := path.Join(targetDir, strings.ToLower(resPath))
if err := os.MkdirAll(path.Dir(sysPath), 0777); err != nil {
return err
}
@ -92,6 +93,7 @@ func main() {
var (
filter = flag.String("filter", "**", "wildcard file filter")
targetDir = flag.String("target", ".", "target directory")
lowercase = flag.Bool("lowercase", true, "extract with lowercase paths")
)
flag.Usage = func() {
@ -116,7 +118,7 @@ func main() {
}
case "extract":
for i := 1; i < flag.NArg(); i++ {
if err := extract(flag.Arg(i), *filter, *targetDir); err != nil {
if err := extract(flag.Arg(i), *filter, *targetDir, *lowercase); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}