Error while unzipping a apk and jar files. Normal zip files are getting unzipped perfect.
:no such file or directory error
package main
import (
"archive/zip"
"flag"
"fmt"
"os"
"io"
"path/filepath"
//"strings"
//"log"
)
func main() {
flag.Parse() //parse command line arguments
zipfile := flag.Arg(0)
//check zip file name is passed as argument
if zipfile == "" {
fmt.Println("Usage: godex pathofapk")
os.Exit(1)
}
//open reader to read zip file
reader, err := zip.OpenReader(zipfile)
if err != nil {
fmt.Println(err)
os.Exit(1)
} // check for valid zip file
defer reader.Close()
for _, f := range reader.Reader.File {
zipped, err := f.Open()
//fmt.Println(f)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer zipped.Close()
path := filepath.Join("", f.Name)
if f.FileInfo().IsDir() {
os.MkdirAll(path, f.Mode())
fmt.Println("Creating Directory", path)
} else {
writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, f.Mode())
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer writer.Close()
if _, err = io.Copy(writer, zipped); err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Decompressing: ", path)
}
}
//os.Rename("goSwiff_v3.1.1_UAT.apk","goSwiff_v3.1.1_UAT.zip")
}
Error while unzipping a apk and jar files. Normal zip files are getting unzipped perfect.
:no such file or directory error
package main
import (
"archive/zip"
"flag"
"fmt"
"os"
"io"
"path/filepath"
//"strings"
//"log"
)
func main() {
flag.Parse() //parse command line arguments
zipfile := flag.Arg(0)
//check zip file name is passed as argument
if zipfile == "" {
fmt.Println("Usage: godex pathofapk")
os.Exit(1)
}
//open reader to read zip file
reader, err := zip.OpenReader(zipfile)
if err != nil {
fmt.Println(err)
os.Exit(1)
} // check for valid zip file
defer reader.Close()
}