1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// An opaque structure representing an opened directory.
15type Dir struct {
16 _ structs.HostLayout
17}
18
19var xDirGLibType func() types.GType
20
21func DirGLibType() types.GType {
22 return xDirGLibType()
23}
24
25func (x *Dir) GoPointer() uintptr {
26 return uintptr(unsafe.Pointer(x))
27}
28
29var xDirOpen func(string, uint, **Error) *Dir
30
31// Opens a directory for reading. The names of the files in the
32// directory can then be retrieved using g_dir_read_name(). Note
33// that the ordering is not defined.
34func DirOpen(PathVar string, FlagsVar uint) (*Dir, error) {
35 var cerr *Error
36
37 cret := xDirOpen(PathVar, FlagsVar, &cerr)
38 if cerr == nil {
39 return cret, nil
40 }
41 return cret, cerr
42
43}
44
45var xDirClose func(uintptr)
46
47// Closes the directory immediately and decrements the reference count.
48//
49// Once the reference count reaches zero, the `GDir` structure itself will be
50// freed. Prior to GLib 2.80, `GDir` was not reference counted.
51//
52// It is an error to call any of the `GDir` methods other than
53// [method@GLib.Dir.ref] and [method@GLib.Dir.unref] on a `GDir` after calling
54// [method@GLib.Dir.close] on it.
55func (x *Dir) Close() {
56
57 xDirClose(x.GoPointer())
58
59}
60
61var xDirReadName func(uintptr) string
62
63// Retrieves the name of another entry in the directory, or %NULL.
64// The order of entries returned from this function is not defined,
65// and may vary by file system or other operating-system dependent
66// factors.
67//
68// %NULL may also be returned in case of errors. On Unix, you can
69// check `errno` to find out if %NULL was returned because of an error.
70//
71// On Unix, the '.' and '..' entries are omitted, and the returned
72// name is in the on-disk encoding.
73//
74// On Windows, as is true of all GLib functions which operate on
75// filenames, the returned name is in UTF-8.
76func (x *Dir) ReadName() string {
77
78 cret := xDirReadName(x.GoPointer())
79 return cret
80}
81
82var xDirRef func(uintptr) *Dir
83
84// Increment the reference count of `dir`.
85func (x *Dir) Ref() *Dir {
86
87 cret := xDirRef(x.GoPointer())
88 return cret
89}
90
91var xDirRewind func(uintptr)
92
93// Resets the given directory. The next call to g_dir_read_name()
94// will return the first entry again.
95func (x *Dir) Rewind() {
96
97 xDirRewind(x.GoPointer())
98
99}
100
101var xDirUnref func(uintptr)
102
103// Decrements the reference count of `dir`.
104//
105// Once the reference count reaches zero, the directory will be closed and all
106// resources associated with it will be freed. If [method@GLib.Dir.close] is
107// called when the reference count is greater than zero, the directory is closed
108// but the `GDir` structure will not be freed until its reference count reaches
109// zero.
110//
111// It is an error to call any of the `GDir` methods other than
112// [method@GLib.Dir.ref] and [method@GLib.Dir.unref] on a `GDir` after calling
113// [method@GLib.Dir.close] on it.
114func (x *Dir) Unref() {
115
116 xDirUnref(x.GoPointer())
117
118}
119
120func init() {
121 core.SetPackageName("GLIB", "glib-2.0")
122 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
123 var libs []uintptr
124 for _, libPath := range core.GetPaths("GLIB") {
125 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
126 if err != nil {
127 panic(err)
128 }
129 libs = append(libs, lib)
130 }
131
132 core.PuregoSafeRegister(&xDirGLibType, libs, "g_dir_get_type")
133
134 core.PuregoSafeRegister(&xDirOpen, libs, "g_dir_open")
135
136 core.PuregoSafeRegister(&xDirClose, libs, "g_dir_close")
137 core.PuregoSafeRegister(&xDirReadName, libs, "g_dir_read_name")
138 core.PuregoSafeRegister(&xDirRef, libs, "g_dir_ref")
139 core.PuregoSafeRegister(&xDirRewind, libs, "g_dir_rewind")
140 core.PuregoSafeRegister(&xDirUnref, libs, "g_dir_unref")
141
142}