Skip to content

Commit b8f2c9e

Browse files
committed
Adds option to set output folder, implements #29
1 parent 98e3c1b commit b8f2c9e

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

acquisition/acquisition.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,30 @@ type Acquisition struct {
3636
}
3737

3838
// New returns a new Acquisition instance.
39-
func New() (*Acquisition, error) {
39+
func New(path string) (*Acquisition, error) {
4040
acq := Acquisition{
4141
UUID: uuid.New().String(),
4242
Started: time.Now().UTC(),
4343
AndroidQFVersion: utils.Version,
4444
}
4545

46-
acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
47-
err := os.Mkdir(acq.StoragePath, 0o755)
48-
if err != nil {
49-
return nil, fmt.Errorf("failed to create acquisition folder: %v", err)
50-
}
46+
if path == "" {
47+
acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
48+
} else {
49+
acq.StoragePath = path
50+
}
51+
// Check if the path exist
52+
stat, err := os.Stat(acq.StoragePath)
53+
if os.IsNotExist(err) {
54+
err := os.Mkdir(acq.StoragePath, 0o755)
55+
if err != nil {
56+
return nil, fmt.Errorf("failed to create acquisition folder: %v", err)
57+
}
58+
} else {
59+
if !stat.IsDir() {
60+
return nil, fmt.Errorf("path exist and is not a folder")
61+
}
62+
}
5163

5264
// Get system information first to get tmp folder
5365
err = acq.GetSystemInformation()

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func main() {
4444
var list_modules bool
4545
var fast bool
4646
var module string
47+
var output_folder string
4748

4849
// Command line options
4950
flag.BoolVar(&verbose, "verbose", false, "Verbose mode")
@@ -54,6 +55,8 @@ func main() {
5455
flag.BoolVar(&list_modules, "l", false, "List modules and exit")
5556
flag.StringVar(&module, "module", "", "Only execute a specific module")
5657
flag.StringVar(&module, "m", "", "Only execute a specific module")
58+
flag.StringVar(&output_folder, "output", "", "Output folder")
59+
flag.StringVar(&output_folder, "o", "", "Output folder")
5760
flag.BoolVar(&version_flag, "version", false, "Show version")
5861

5962
flag.Parse()
@@ -92,14 +95,14 @@ func main() {
9295
time.Sleep(5 * time.Second)
9396
}
9497

95-
acq, err := acquisition.New()
98+
acq, err := acquisition.New(output_folder)
9699
if err != nil {
97100
log.Debug(err)
98101
log.FatalExc("Impossible to initialise the acquisition", err)
99102
}
100103

101104
// Start acquisitions
102-
log.Info(fmt.Sprintf("Started new acquisition %s", acq.UUID))
105+
log.Info(fmt.Sprintf("Started new acquisition in %s", acq.StoragePath))
103106

104107
mods := modules.List()
105108
for _, mod := range mods {

0 commit comments

Comments
 (0)