-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathverify.go
41 lines (31 loc) · 1022 Bytes
/
verify.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
// Copyright 2017 The go-darwin Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package hdiutil
import "os/exec"
// verifyFlag implements a hdiutil verify command flag interface.
type verifyFlag interface {
verifyFlag() []string
}
type verifyCache bool
func (v verifyCache) verifyFlag() []string { return boolFlag("cache", bool(v)) }
const (
// VerifyCache do cache checksum-verification.
VerifyCache verifyCache = true
// VerifyNoCache do not cache checksum-verification cache.
VerifyNoCache verifyCache = false
)
// Verify compute the checksum of a "read-only" or "compressed" image and verify it against the value stored in the image.
func Verify(image string, flags ...verifyFlag) error {
cmd := exec.Command(hdiutilPath, "verify", image)
if len(flags) > 0 {
for _, flag := range flags {
cmd.Args = append(cmd.Args, flag.verifyFlag()...)
}
}
err := cmd.Run()
if err != nil {
return err
}
return nil
}