-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands_fs.go
44 lines (35 loc) · 943 Bytes
/
commands_fs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package goxbdm
import "github.com/0xdeafcafe/go-xbdm/models"
import "fmt"
// ListDrives ..
func (client *Client) ListDrives() ([]*models.Drive, error) {
_, err := client.SendCommand("drivelist")
if err != nil {
return nil, err
}
body, err := client.ReadMultilineResponse()
if err != nil {
return nil, err
}
drives := make([]*models.Drive, len(body))
for i := 0; i < len(body); i++ {
drives[i] = models.NewDrive(body[i])
}
return drives, nil
}
// ListDirectory ..
func (client *Client) ListDirectory(dir string) ([]*models.DirectoryItem, error) {
_, err := client.SendCommand(fmt.Sprintf(`dirlist name="%s"`, dir))
if err != nil {
return nil, err
}
body, err := client.ReadMultilineResponse()
if err != nil {
return nil, err
}
directoryItems := make([]*models.DirectoryItem, len(body))
for i := 0; i < len(body); i++ {
directoryItems[i] = models.NewDirectoryItem(body[i])
}
return directoryItems, nil
}