mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
cmd/gio: handle subdirectories in apk files
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+19
-11
@@ -10,7 +10,6 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -332,18 +331,24 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err error) {
|
||||
}()
|
||||
apkw := newZipWriter(ap_)
|
||||
defer apkw.Close()
|
||||
apkFiles, err := filepath.Glob(filepath.Join(apkDir, "*"))
|
||||
err = filepath.Walk(apkDir, func(path string, f os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
zpath := path[len(apkDir)+1:]
|
||||
if filepath.Base(path) == "resources.arsc" {
|
||||
apkw.Store(zpath, path)
|
||||
} else {
|
||||
apkw.Add(zpath, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range apkFiles {
|
||||
name := filepath.Base(f)
|
||||
if name == "resources.arsc" {
|
||||
apkw.Store(name, f)
|
||||
} else {
|
||||
apkw.Add(name, f)
|
||||
}
|
||||
}
|
||||
for _, a := range bi.archs {
|
||||
arch := allArchs[a]
|
||||
libFile := filepath.Join(arch.jniArch, "libgio.so")
|
||||
@@ -395,7 +400,10 @@ func unzip(dir, zipfile string) (err error) {
|
||||
}
|
||||
defer zipr.Close()
|
||||
for _, f := range zipr.File {
|
||||
path := filepath.Join(dir, path.Base(f.Name))
|
||||
path := filepath.Join(dir, f.Name)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
out, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user