diff --git a/.gitignore b/.gitignore index a3b2e0f..2bd69c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -*.mpq +asset diff --git a/formats/mpq/mpq.go b/formats/mpq/mpq.go index 7700b9e..38d659a 100644 --- a/formats/mpq/mpq.go +++ b/formats/mpq/mpq.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "math" + "os" "strings" "unsafe" ) @@ -124,7 +125,7 @@ func (a *archive) Close() error { } func (a *archive) OpenFile(path string) (File, error) { - cs := C.CString(path) + cs := C.CString(strings.Replace(path, string(os.PathSeparator), "\\", -1)) defer C.free(unsafe.Pointer(cs)) file := &file{size: math.MaxUint32} @@ -153,6 +154,7 @@ func (a *archive) GetPaths() ([]string, error) { for _, line := range strings.Split(string(buff.Bytes()), "\r\n") { line = strings.TrimSpace(line) + line = strings.Replace(line, "\\", string(os.PathSeparator), -1) if len(line) > 0 { a.paths = append(a.paths, line) } diff --git a/tools/mpq/mpq.go b/tools/mpq/mpq.go index 19262a9..a15c3a0 100644 --- a/tools/mpq/mpq.go +++ b/tools/mpq/mpq.go @@ -86,7 +86,7 @@ func extract(mpqPath, filter, targetDir string) error { func main() { var ( - filter = flag.String("filter", "*.*", "wildcard file filter") + filter = flag.String("filter", "**", "wildcard file filter") targetDir = flag.String("target", ".", "target directory") ) @@ -107,14 +107,14 @@ func main() { case "list": for i := 1; i < flag.NArg(); i++ { if err := list(flag.Arg(i), *filter); err != nil { - fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, err) os.Exit(1) } } case "extract": for i := 1; i < flag.NArg(); i++ { if err := extract(flag.Arg(i), *filter, *targetDir); err != nil { - fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, err) os.Exit(1) } }