forked from remyoudompheng/go-alpm
-
Notifications
You must be signed in to change notification settings - Fork 14
/
trans.go
54 lines (42 loc) · 958 Bytes
/
trans.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
45
46
47
48
49
50
51
52
53
54
// db.go - Functions for database handling.
//
// Copyright (c) 2013 The go-alpm Authors
//
// MIT Licensed. See LICENSE for details.
package alpm
/*
#include <alpm.h>
*/
import "C"
import (
"unsafe"
)
func (h *Handle) TransInit(flags TransFlag) error {
ret := C.alpm_trans_init(h.ptr, C.int(flags))
if ret != 0 {
return h.LastError()
}
return nil
}
func (h *Handle) TransRelease() error {
ret := C.alpm_trans_release(h.ptr)
if ret != 0 {
return h.LastError()
}
return nil
}
func (h *Handle) TransGetAdd() PackageList {
pkgs := C.alpm_trans_get_add(h.ptr)
return PackageList{(*list)(unsafe.Pointer(pkgs)), *h}
}
func (h *Handle) TransGetRemove() PackageList {
pkgs := C.alpm_trans_get_remove(h.ptr)
return PackageList{(*list)(unsafe.Pointer(pkgs)), *h}
}
func (h *Handle) TransGetFlags() (TransFlag, error) {
flags := C.alpm_trans_get_flags(h.ptr)
if flags == -1 {
return -1, h.LastError()
}
return TransFlag(flags), nil
}