@@ -48,8 +48,21 @@ func extractPayloadBin(filename string) string {
48
48
func main () {
49
49
runtime .GOMAXPROCS (runtime .NumCPU ())
50
50
51
- list := flag .Bool ("l" , false , "Show list of partitions in payload.bin" )
52
- partitions := flag .String ("p" , "" , "Dump only selected partitions" )
51
+ var (
52
+ list bool
53
+ partitions string
54
+ outputDirectory string
55
+ concurrency int
56
+ )
57
+
58
+ flag .BoolVar (& list , "list" , false , "Show list of partitions in payload.bin" )
59
+ flag .BoolVar (& list , "l" , false , "Show list of partitions in payload.bin (shorthand)" )
60
+ flag .StringVar (& partitions , "partitions" , "" , "Dump only selected partitions (comma-separated)" )
61
+ flag .StringVar (& partitions , "p" , "" , "Dump only selected partitions (comma-separated) (shorthand)" )
62
+ flag .StringVar (& outputDirectory , "output" , "" , "Set output directory" )
63
+ flag .StringVar (& outputDirectory , "o" , "" , "Set output directory (shorthand)" )
64
+ flag .IntVar (& concurrency , "concurrency" , 4 , "Number of multiple workers to extract" )
65
+ flag .IntVar (& concurrency , "c" , 4 , "Number of multiple workers to extract (shorthand)" )
53
66
flag .Parse ()
54
67
55
68
if flag .NArg () == 0 {
@@ -79,17 +92,27 @@ func main() {
79
92
}
80
93
payload .Init ()
81
94
82
- if * list {
95
+ if list {
83
96
return
84
97
}
85
98
86
99
now := time .Now ()
87
- targetDirectory := fmt .Sprintf ("extracted_%d%02d%02d_%02d%02d%02d" , now .Year (), now .Month (), now .Day (), now .Hour (), now .Minute (), now .Second ())
88
- if err := os .Mkdir (targetDirectory , 0755 ); err != nil {
89
- log .Fatal ("Failed to create target directory" )
100
+
101
+ var targetDirectory = outputDirectory
102
+ if targetDirectory == "" {
103
+ targetDirectory = fmt .Sprintf ("extracted_%d%02d%02d_%02d%02d%02d" , now .Year (), now .Month (), now .Day (), now .Hour (), now .Minute (), now .Second ())
104
+ }
105
+ if _ , err := os .Stat (targetDirectory ); os .IsNotExist (err ) {
106
+ if err := os .Mkdir (targetDirectory , 0755 ); err != nil {
107
+ log .Fatal ("Failed to create target directory" )
108
+ }
90
109
}
91
- if * partitions != "" {
92
- if err := payload .ExtractSelected (targetDirectory , strings .Split (* partitions , "," )); err != nil {
110
+
111
+ payload .SetConcurrency (concurrency )
112
+ fmt .Printf ("Number of workers: %d\n " , payload .GetConcurrency ())
113
+
114
+ if partitions != "" {
115
+ if err := payload .ExtractSelected (targetDirectory , strings .Split (partitions , "," )); err != nil {
93
116
log .Fatal (err )
94
117
}
95
118
} else {
0 commit comments