diff --git a/amlCRC.go b/AmlCRC/amlCRC.go similarity index 92% rename from amlCRC.go rename to AmlCRC/amlCRC.go index 56e7a58..c6789ea 100644 --- a/amlCRC.go +++ b/AmlCRC/amlCRC.go @@ -1,4 +1,4 @@ -package AmlImg +package AmlCRC import "hash/crc32" diff --git a/cli/main.go b/AmlImg.go similarity index 81% rename from cli/main.go rename to AmlImg.go index 4dbdc3a..7d0c061 100644 --- a/cli/main.go +++ b/AmlImg.go @@ -8,44 +8,9 @@ import ( "os" "strings" - "github.com/hzyitc/AmlImg" + "github.com/hzyitc/AmlImg/AmlImg" ) -var version = "v0.0.0" - -func usage() { - print(os.Args[0] + " (" + version + ")\n") - print("Usage:\n") - print(" " + os.Args[0] + " unpack \n") - print(" " + os.Args[0] + " pack \n") -} - -func main() { - if len(os.Args) != 4 { - usage() - return - } - - switch os.Args[1] { - case "unpack": - os.MkdirAll(os.Args[3], 0755) - - err := unpack(os.Args[2], os.Args[3]) - if err != nil { - println(err.Error()) - return - } - - case "pack": - err := pack(os.Args[2], os.Args[3]) - if err != nil { - println(err.Error()) - return - } - - } -} - func unpack(filePath, extractPath string) error { img, err := AmlImg.NewReader(filePath, true) if err != nil { diff --git a/header.go b/AmlImg/header.go similarity index 100% rename from header.go rename to AmlImg/header.go diff --git a/item.go b/AmlImg/item.go similarity index 100% rename from item.go rename to AmlImg/item.go diff --git a/reader.go b/AmlImg/reader.go similarity index 95% rename from reader.go rename to AmlImg/reader.go index a184402..2bc65a8 100644 --- a/reader.go +++ b/AmlImg/reader.go @@ -6,6 +6,8 @@ import ( "fmt" "io" "os" + + "github.com/hzyitc/AmlImg/AmlCRC" ) type ImageReader struct { @@ -42,7 +44,7 @@ func NewReader(path string, check bool) (*ImageReader, error) { var buf [4096]byte for { n, err := file.Read(buf[:]) - crc = AmlCRC(crc, buf[:n]) + crc = AmlCRC.AmlCRC(crc, buf[:n]) if errors.Is(err, io.EOF) { break } else if err != nil { diff --git a/writer.go b/AmlImg/writer.go similarity index 97% rename from writer.go rename to AmlImg/writer.go index 76d6044..6b12155 100644 --- a/writer.go +++ b/AmlImg/writer.go @@ -6,6 +6,8 @@ import ( "fmt" "io" "os" + + "github.com/hzyitc/AmlImg/AmlCRC" ) type ImageWriter struct { @@ -125,7 +127,7 @@ func (w *ImageWriter) Write(path string, version uint32) error { var buf [4096]byte for { n, err := file.Read(buf[:]) - crc = AmlCRC(crc, buf[:n]) + crc = AmlCRC.AmlCRC(crc, buf[:n]) if errors.Is(err, io.EOF) { break } else if err != nil { diff --git a/buildAllPlatforms.sh b/buildAllPlatforms.sh index ce0191c..0854fe7 100644 --- a/buildAllPlatforms.sh +++ b/buildAllPlatforms.sh @@ -1,7 +1,7 @@ #!/bin/bash PROGRAM="AmlImg" -CLI="./cli" +CLI="./" OUTPUT="bin/" LDFLAGS="-s -w" diff --git a/main.go b/main.go new file mode 100644 index 0000000..11b7af0 --- /dev/null +++ b/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "os" +) + +var version = "v0.0.0" + +func usage() { + print(os.Args[0] + " (" + version + ")\n") + print("Usage:\n") + print(" " + os.Args[0] + " unpack \n") + print(" " + os.Args[0] + " pack \n") +} + +func main() { + if len(os.Args) != 4 { + usage() + return + } + + switch os.Args[1] { + case "unpack": + os.MkdirAll(os.Args[3], 0755) + + err := unpack(os.Args[2], os.Args[3]) + if err != nil { + println(err.Error()) + return + } + + case "pack": + err := pack(os.Args[2], os.Args[3]) + if err != nil { + println(err.Error()) + return + } + } +}