1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
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/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type FileEnumeratorClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xNextFile uintptr
22
23 xCloseFn uintptr
24
25 xNextFilesAsync uintptr
26
27 xNextFilesFinish uintptr
28
29 xCloseAsync uintptr
30
31 xCloseFinish uintptr
32
33 xGReserved1 uintptr
34
35 xGReserved2 uintptr
36
37 xGReserved3 uintptr
38
39 xGReserved4 uintptr
40
41 xGReserved5 uintptr
42
43 xGReserved6 uintptr
44
45 xGReserved7 uintptr
46}
47
48func (x *FileEnumeratorClass) GoPointer() uintptr {
49 return uintptr(unsafe.Pointer(x))
50}
51
52// OverrideNextFile sets the "next_file" callback function.
53func (x *FileEnumeratorClass) OverrideNextFile(cb func(*FileEnumerator, *Cancellable) *FileInfo) {
54 if cb == nil {
55 x.xNextFile = 0
56 } else {
57 x.xNextFile = purego.NewCallback(func(EnumeratorVarp uintptr, CancellableVarp uintptr) uintptr {
58 ret := cb(FileEnumeratorNewFromInternalPtr(EnumeratorVarp), CancellableNewFromInternalPtr(CancellableVarp))
59 if ret == nil {
60 return 0
61 }
62 return ret.GoPointer()
63 })
64 }
65}
66
67// GetNextFile gets the "next_file" callback function.
68func (x *FileEnumeratorClass) GetNextFile() func(*FileEnumerator, *Cancellable) *FileInfo {
69 if x.xNextFile == 0 {
70 return nil
71 }
72 var rawCallback func(EnumeratorVarp uintptr, CancellableVarp uintptr) uintptr
73 purego.RegisterFunc(&rawCallback, x.xNextFile)
74 return func(EnumeratorVar *FileEnumerator, CancellableVar *Cancellable) *FileInfo {
75 rawRet := rawCallback(EnumeratorVar.GoPointer(), CancellableVar.GoPointer())
76 if rawRet == 0 {
77 return nil
78 }
79 ret := &FileInfo{}
80 ret.Ptr = rawRet
81 return ret
82 }
83}
84
85// OverrideCloseFn sets the "close_fn" callback function.
86func (x *FileEnumeratorClass) OverrideCloseFn(cb func(*FileEnumerator, *Cancellable) bool) {
87 if cb == nil {
88 x.xCloseFn = 0
89 } else {
90 x.xCloseFn = purego.NewCallback(func(EnumeratorVarp uintptr, CancellableVarp uintptr) bool {
91 return cb(FileEnumeratorNewFromInternalPtr(EnumeratorVarp), CancellableNewFromInternalPtr(CancellableVarp))
92 })
93 }
94}
95
96// GetCloseFn gets the "close_fn" callback function.
97func (x *FileEnumeratorClass) GetCloseFn() func(*FileEnumerator, *Cancellable) bool {
98 if x.xCloseFn == 0 {
99 return nil
100 }
101 var rawCallback func(EnumeratorVarp uintptr, CancellableVarp uintptr) bool
102 purego.RegisterFunc(&rawCallback, x.xCloseFn)
103 return func(EnumeratorVar *FileEnumerator, CancellableVar *Cancellable) bool {
104 return rawCallback(EnumeratorVar.GoPointer(), CancellableVar.GoPointer())
105 }
106}
107
108// OverrideNextFilesAsync sets the "next_files_async" callback function.
109func (x *FileEnumeratorClass) OverrideNextFilesAsync(cb func(*FileEnumerator, int, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
110 if cb == nil {
111 x.xNextFilesAsync = 0
112 } else {
113 x.xNextFilesAsync = purego.NewCallback(func(EnumeratorVarp uintptr, NumFilesVarp int, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
114 cb(FileEnumeratorNewFromInternalPtr(EnumeratorVarp), NumFilesVarp, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
115 })
116 }
117}
118
119// GetNextFilesAsync gets the "next_files_async" callback function.
120func (x *FileEnumeratorClass) GetNextFilesAsync() func(*FileEnumerator, int, int, *Cancellable, *AsyncReadyCallback, uintptr) {
121 if x.xNextFilesAsync == 0 {
122 return nil
123 }
124 var rawCallback func(EnumeratorVarp uintptr, NumFilesVarp int, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
125 purego.RegisterFunc(&rawCallback, x.xNextFilesAsync)
126 return func(EnumeratorVar *FileEnumerator, NumFilesVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
127 rawCallback(EnumeratorVar.GoPointer(), NumFilesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
128 }
129}
130
131// OverrideNextFilesFinish sets the "next_files_finish" callback function.
132func (x *FileEnumeratorClass) OverrideNextFilesFinish(cb func(*FileEnumerator, AsyncResult) *glib.List) {
133 if cb == nil {
134 x.xNextFilesFinish = 0
135 } else {
136 x.xNextFilesFinish = purego.NewCallback(func(EnumeratorVarp uintptr, ResultVarp uintptr) *glib.List {
137 return cb(FileEnumeratorNewFromInternalPtr(EnumeratorVarp), &AsyncResultBase{Ptr: ResultVarp})
138 })
139 }
140}
141
142// GetNextFilesFinish gets the "next_files_finish" callback function.
143func (x *FileEnumeratorClass) GetNextFilesFinish() func(*FileEnumerator, AsyncResult) *glib.List {
144 if x.xNextFilesFinish == 0 {
145 return nil
146 }
147 var rawCallback func(EnumeratorVarp uintptr, ResultVarp uintptr) *glib.List
148 purego.RegisterFunc(&rawCallback, x.xNextFilesFinish)
149 return func(EnumeratorVar *FileEnumerator, ResultVar AsyncResult) *glib.List {
150 return rawCallback(EnumeratorVar.GoPointer(), ResultVar.GoPointer())
151 }
152}
153
154// OverrideCloseAsync sets the "close_async" callback function.
155func (x *FileEnumeratorClass) OverrideCloseAsync(cb func(*FileEnumerator, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
156 if cb == nil {
157 x.xCloseAsync = 0
158 } else {
159 x.xCloseAsync = purego.NewCallback(func(EnumeratorVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
160 cb(FileEnumeratorNewFromInternalPtr(EnumeratorVarp), IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
161 })
162 }
163}
164
165// GetCloseAsync gets the "close_async" callback function.
166func (x *FileEnumeratorClass) GetCloseAsync() func(*FileEnumerator, int, *Cancellable, *AsyncReadyCallback, uintptr) {
167 if x.xCloseAsync == 0 {
168 return nil
169 }
170 var rawCallback func(EnumeratorVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
171 purego.RegisterFunc(&rawCallback, x.xCloseAsync)
172 return func(EnumeratorVar *FileEnumerator, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
173 rawCallback(EnumeratorVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
174 }
175}
176
177// OverrideCloseFinish sets the "close_finish" callback function.
178func (x *FileEnumeratorClass) OverrideCloseFinish(cb func(*FileEnumerator, AsyncResult) bool) {
179 if cb == nil {
180 x.xCloseFinish = 0
181 } else {
182 x.xCloseFinish = purego.NewCallback(func(EnumeratorVarp uintptr, ResultVarp uintptr) bool {
183 return cb(FileEnumeratorNewFromInternalPtr(EnumeratorVarp), &AsyncResultBase{Ptr: ResultVarp})
184 })
185 }
186}
187
188// GetCloseFinish gets the "close_finish" callback function.
189func (x *FileEnumeratorClass) GetCloseFinish() func(*FileEnumerator, AsyncResult) bool {
190 if x.xCloseFinish == 0 {
191 return nil
192 }
193 var rawCallback func(EnumeratorVarp uintptr, ResultVarp uintptr) bool
194 purego.RegisterFunc(&rawCallback, x.xCloseFinish)
195 return func(EnumeratorVar *FileEnumerator, ResultVar AsyncResult) bool {
196 return rawCallback(EnumeratorVar.GoPointer(), ResultVar.GoPointer())
197 }
198}
199
200// OverrideGReserved1 sets the "_g_reserved1" callback function.
201func (x *FileEnumeratorClass) OverrideGReserved1(cb func()) {
202 if cb == nil {
203 x.xGReserved1 = 0
204 } else {
205 x.xGReserved1 = purego.NewCallback(func() {
206 cb()
207 })
208 }
209}
210
211// GetGReserved1 gets the "_g_reserved1" callback function.
212func (x *FileEnumeratorClass) GetGReserved1() func() {
213 if x.xGReserved1 == 0 {
214 return nil
215 }
216 var rawCallback func()
217 purego.RegisterFunc(&rawCallback, x.xGReserved1)
218 return func() {
219 rawCallback()
220 }
221}
222
223// OverrideGReserved2 sets the "_g_reserved2" callback function.
224func (x *FileEnumeratorClass) OverrideGReserved2(cb func()) {
225 if cb == nil {
226 x.xGReserved2 = 0
227 } else {
228 x.xGReserved2 = purego.NewCallback(func() {
229 cb()
230 })
231 }
232}
233
234// GetGReserved2 gets the "_g_reserved2" callback function.
235func (x *FileEnumeratorClass) GetGReserved2() func() {
236 if x.xGReserved2 == 0 {
237 return nil
238 }
239 var rawCallback func()
240 purego.RegisterFunc(&rawCallback, x.xGReserved2)
241 return func() {
242 rawCallback()
243 }
244}
245
246// OverrideGReserved3 sets the "_g_reserved3" callback function.
247func (x *FileEnumeratorClass) OverrideGReserved3(cb func()) {
248 if cb == nil {
249 x.xGReserved3 = 0
250 } else {
251 x.xGReserved3 = purego.NewCallback(func() {
252 cb()
253 })
254 }
255}
256
257// GetGReserved3 gets the "_g_reserved3" callback function.
258func (x *FileEnumeratorClass) GetGReserved3() func() {
259 if x.xGReserved3 == 0 {
260 return nil
261 }
262 var rawCallback func()
263 purego.RegisterFunc(&rawCallback, x.xGReserved3)
264 return func() {
265 rawCallback()
266 }
267}
268
269// OverrideGReserved4 sets the "_g_reserved4" callback function.
270func (x *FileEnumeratorClass) OverrideGReserved4(cb func()) {
271 if cb == nil {
272 x.xGReserved4 = 0
273 } else {
274 x.xGReserved4 = purego.NewCallback(func() {
275 cb()
276 })
277 }
278}
279
280// GetGReserved4 gets the "_g_reserved4" callback function.
281func (x *FileEnumeratorClass) GetGReserved4() func() {
282 if x.xGReserved4 == 0 {
283 return nil
284 }
285 var rawCallback func()
286 purego.RegisterFunc(&rawCallback, x.xGReserved4)
287 return func() {
288 rawCallback()
289 }
290}
291
292// OverrideGReserved5 sets the "_g_reserved5" callback function.
293func (x *FileEnumeratorClass) OverrideGReserved5(cb func()) {
294 if cb == nil {
295 x.xGReserved5 = 0
296 } else {
297 x.xGReserved5 = purego.NewCallback(func() {
298 cb()
299 })
300 }
301}
302
303// GetGReserved5 gets the "_g_reserved5" callback function.
304func (x *FileEnumeratorClass) GetGReserved5() func() {
305 if x.xGReserved5 == 0 {
306 return nil
307 }
308 var rawCallback func()
309 purego.RegisterFunc(&rawCallback, x.xGReserved5)
310 return func() {
311 rawCallback()
312 }
313}
314
315// OverrideGReserved6 sets the "_g_reserved6" callback function.
316func (x *FileEnumeratorClass) OverrideGReserved6(cb func()) {
317 if cb == nil {
318 x.xGReserved6 = 0
319 } else {
320 x.xGReserved6 = purego.NewCallback(func() {
321 cb()
322 })
323 }
324}
325
326// GetGReserved6 gets the "_g_reserved6" callback function.
327func (x *FileEnumeratorClass) GetGReserved6() func() {
328 if x.xGReserved6 == 0 {
329 return nil
330 }
331 var rawCallback func()
332 purego.RegisterFunc(&rawCallback, x.xGReserved6)
333 return func() {
334 rawCallback()
335 }
336}
337
338// OverrideGReserved7 sets the "_g_reserved7" callback function.
339func (x *FileEnumeratorClass) OverrideGReserved7(cb func()) {
340 if cb == nil {
341 x.xGReserved7 = 0
342 } else {
343 x.xGReserved7 = purego.NewCallback(func() {
344 cb()
345 })
346 }
347}
348
349// GetGReserved7 gets the "_g_reserved7" callback function.
350func (x *FileEnumeratorClass) GetGReserved7() func() {
351 if x.xGReserved7 == 0 {
352 return nil
353 }
354 var rawCallback func()
355 purego.RegisterFunc(&rawCallback, x.xGReserved7)
356 return func() {
357 rawCallback()
358 }
359}
360
361type FileEnumeratorPrivate struct {
362 _ structs.HostLayout
363}
364
365func (x *FileEnumeratorPrivate) GoPointer() uintptr {
366 return uintptr(unsafe.Pointer(x))
367}
368
369// `GFileEnumerator` allows you to operate on a set of [iface@Gio.File] objects,
370// returning a [class@Gio.FileInfo] structure for each file enumerated (e.g.
371// [method@Gio.File.enumerate_children] will return a `GFileEnumerator` for each
372// of the children within a directory).
373//
374// To get the next file's information from a `GFileEnumerator`, use
375// [method@Gio.FileEnumerator.next_file] or its asynchronous version,
376// [method@Gio.FileEnumerator.next_files_async]. Note that the asynchronous
377// version will return a list of [class@Gio.FileInfo] objects, whereas the
378// synchronous will only return the next file in the enumerator.
379//
380// The ordering of returned files is unspecified for non-Unix
381// platforms; for more information, see [method@GLib.Dir.read_name]. On Unix,
382// when operating on local files, returned files will be sorted by
383// inode number. Effectively you can assume that the ordering of
384// returned files will be stable between successive calls (and
385// applications) assuming the directory is unchanged.
386//
387// If your application needs a specific ordering, such as by name or
388// modification time, you will have to implement that in your
389// application code.
390//
391// To close a `GFileEnumerator`, use [method@Gio.FileEnumerator.close], or
392// its asynchronous version, [method@Gio.FileEnumerator.close_async]. Once
393// a `GFileEnumerator` is closed, no further actions may be performed
394// on it, and it should be freed with [method@GObject.Object.unref].
395type FileEnumerator struct {
396 gobject.Object
397}
398
399var xFileEnumeratorGLibType func() types.GType
400
401func FileEnumeratorGLibType() types.GType {
402 return xFileEnumeratorGLibType()
403}
404
405func FileEnumeratorNewFromInternalPtr(ptr uintptr) *FileEnumerator {
406 cls := &FileEnumerator{}
407 cls.Ptr = ptr
408 return cls
409}
410
411var xFileEnumeratorClose func(uintptr, uintptr, **glib.Error) bool
412
413// Releases all resources used by this enumerator, making the
414// enumerator return %G_IO_ERROR_CLOSED on all calls.
415//
416// This will be automatically called when the last reference
417// is dropped, but you might want to call this function to make
418// sure resources are released as early as possible.
419func (x *FileEnumerator) Close(CancellableVar *Cancellable) (bool, error) {
420 var cerr *glib.Error
421
422 cret := xFileEnumeratorClose(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
423 if cerr == nil {
424 return cret, nil
425 }
426 return cret, cerr
427
428}
429
430var xFileEnumeratorCloseAsync func(uintptr, int, uintptr, uintptr, uintptr)
431
432// Asynchronously closes the file enumerator.
433//
434// If @cancellable is not %NULL, then the operation can be cancelled by
435// triggering the cancellable object from another thread. If the operation
436// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned in
437// g_file_enumerator_close_finish().
438func (x *FileEnumerator) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
439
440 var CallbackVarRef uintptr
441 if CallbackVar != nil {
442 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
443 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
444 CallbackVarRef = cbRefPtr
445 } else {
446 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
447 cbFn := *CallbackVar
448 cbFn(arg0, arg1, arg2)
449 }
450 CallbackVarRef = purego.NewCallback(fcb)
451 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
452 }
453 }
454
455 xFileEnumeratorCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
456
457}
458
459var xFileEnumeratorCloseFinish func(uintptr, uintptr, **glib.Error) bool
460
461// Finishes closing a file enumerator, started from g_file_enumerator_close_async().
462//
463// If the file enumerator was already closed when g_file_enumerator_close_async()
464// was called, then this function will report %G_IO_ERROR_CLOSED in @error, and
465// return %FALSE. If the file enumerator had pending operation when the close
466// operation was started, then this function will report %G_IO_ERROR_PENDING, and
467// return %FALSE. If @cancellable was not %NULL, then the operation may have been
468// cancelled by triggering the cancellable object from another thread. If the operation
469// was cancelled, the error %G_IO_ERROR_CANCELLED will be set, and %FALSE will be
470// returned.
471func (x *FileEnumerator) CloseFinish(ResultVar AsyncResult) (bool, error) {
472 var cerr *glib.Error
473
474 cret := xFileEnumeratorCloseFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
475 if cerr == nil {
476 return cret, nil
477 }
478 return cret, cerr
479
480}
481
482var xFileEnumeratorGetChild func(uintptr, uintptr) uintptr
483
484// Return a new #GFile which refers to the file named by @info in the source
485// directory of @enumerator. This function is primarily intended to be used
486// inside loops with g_file_enumerator_next_file().
487//
488// To use this, %G_FILE_ATTRIBUTE_STANDARD_NAME must have been listed in the
489// attributes list used when creating the #GFileEnumerator.
490//
491// This is a convenience method that's equivalent to:
492// |[<!-- language="C" -->
493//
494// gchar *name = g_file_info_get_name (info);
495// GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr),
496// name);
497//
498// ]|
499func (x *FileEnumerator) GetChild(InfoVar *FileInfo) *FileBase {
500 var cls *FileBase
501
502 cret := xFileEnumeratorGetChild(x.GoPointer(), InfoVar.GoPointer())
503
504 if cret == 0 {
505 return nil
506 }
507 cls = &FileBase{}
508 cls.Ptr = cret
509 return cls
510}
511
512var xFileEnumeratorGetContainer func(uintptr) uintptr
513
514// Get the #GFile container which is being enumerated.
515func (x *FileEnumerator) GetContainer() *FileBase {
516 var cls *FileBase
517
518 cret := xFileEnumeratorGetContainer(x.GoPointer())
519
520 if cret == 0 {
521 return nil
522 }
523 gobject.IncreaseRef(cret)
524 cls = &FileBase{}
525 cls.Ptr = cret
526 return cls
527}
528
529var xFileEnumeratorHasPending func(uintptr) bool
530
531// Checks if the file enumerator has pending operations.
532func (x *FileEnumerator) HasPending() bool {
533
534 cret := xFileEnumeratorHasPending(x.GoPointer())
535 return cret
536}
537
538var xFileEnumeratorIsClosed func(uintptr) bool
539
540// Checks if the file enumerator has been closed.
541func (x *FileEnumerator) IsClosed() bool {
542
543 cret := xFileEnumeratorIsClosed(x.GoPointer())
544 return cret
545}
546
547var xFileEnumeratorIterate func(uintptr, **FileInfo, **File, uintptr, **glib.Error) bool
548
549// This is a version of g_file_enumerator_next_file() that's easier to
550// use correctly from C programs. With g_file_enumerator_next_file(),
551// the gboolean return value signifies "end of iteration or error", which
552// requires allocation of a temporary #GError.
553//
554// In contrast, with this function, a %FALSE return from
555// g_file_enumerator_iterate() *always* means
556// "error". End of iteration is signaled by @out_info or @out_child being %NULL.
557//
558// Another crucial difference is that the references for @out_info and
559// @out_child are owned by @direnum (they are cached as hidden
560// properties). You must not unref them in your own code. This makes
561// memory management significantly easier for C code in combination
562// with loops.
563//
564// Finally, this function optionally allows retrieving a #GFile as
565// well.
566//
567// You must specify at least one of @out_info or @out_child.
568//
569// The code pattern for correctly using g_file_enumerator_iterate() from C
570// is:
571//
572// |[
573// direnum = g_file_enumerate_children (file, ...);
574// while (TRUE)
575//
576// {
577// GFileInfo *info;
578// if (!g_file_enumerator_iterate (direnum, &info, NULL, cancellable, error))
579// goto out;
580// if (!info)
581// break;
582// ... do stuff with "info"; do not unref it! ...
583// }
584//
585// out:
586//
587// g_object_unref (direnum); // Note: frees the last @info
588//
589// ]|
590func (x *FileEnumerator) Iterate(OutInfoVar **FileInfo, OutChildVar **File, CancellableVar *Cancellable) (bool, error) {
591 var cerr *glib.Error
592
593 cret := xFileEnumeratorIterate(x.GoPointer(), OutInfoVar, OutChildVar, CancellableVar.GoPointer(), &cerr)
594 if cerr == nil {
595 return cret, nil
596 }
597 return cret, cerr
598
599}
600
601var xFileEnumeratorNextFile func(uintptr, uintptr, **glib.Error) uintptr
602
603// Returns information for the next file in the enumerated object.
604// Will block until the information is available. The #GFileInfo
605// returned from this function will contain attributes that match the
606// attribute string that was passed when the #GFileEnumerator was created.
607//
608// See the documentation of #GFileEnumerator for information about the
609// order of returned files.
610//
611// On error, returns %NULL and sets @error to the error. If the
612// enumerator is at the end, %NULL will be returned and @error will
613// be unset.
614func (x *FileEnumerator) NextFile(CancellableVar *Cancellable) (*FileInfo, error) {
615 var cls *FileInfo
616 var cerr *glib.Error
617
618 cret := xFileEnumeratorNextFile(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
619
620 if cret == 0 {
621 return nil, cerr
622 }
623 cls = &FileInfo{}
624 cls.Ptr = cret
625 if cerr == nil {
626 return cls, nil
627 }
628 return cls, cerr
629
630}
631
632var xFileEnumeratorNextFilesAsync func(uintptr, int, int, uintptr, uintptr, uintptr)
633
634// Request information for a number of files from the enumerator asynchronously.
635// When all I/O for the operation is finished the @callback will be called with
636// the requested information.
637//
638// See the documentation of #GFileEnumerator for information about the
639// order of returned files.
640//
641// Once the end of the enumerator is reached, or if an error occurs, the
642// @callback will be called with an empty list. In this case, the previous call
643// to g_file_enumerator_next_files_async() will typically have returned fewer
644// than @num_files items.
645//
646// If a request is cancelled the callback will be called with
647// %G_IO_ERROR_CANCELLED.
648//
649// This leads to the following pseudo-code usage:
650// |[
651// g_autoptr(GFile) dir = get_directory ();
652// g_autoptr(GFileEnumerator) enumerator = NULL;
653// g_autolist(GFileInfo) files = NULL;
654// g_autoptr(GError) local_error = NULL;
655//
656// enumerator = yield g_file_enumerate_children_async (dir,
657//
658// G_FILE_ATTRIBUTE_STANDARD_NAME ","
659// G_FILE_ATTRIBUTE_STANDARD_TYPE,
660// G_FILE_QUERY_INFO_NONE,
661// G_PRIORITY_DEFAULT,
662// cancellable,
663// …,
664// &local_error);
665//
666// if (enumerator == NULL)
667//
668// g_error ("Error enumerating: %s", local_error->message);
669//
670// // Loop until no files are returned, either because the end of the enumerator
671// // has been reached, or an error was returned.
672// do
673//
674// {
675// files = yield g_file_enumerator_next_files_async (enumerator,
676// 5, // number of files to request
677// G_PRIORITY_DEFAULT,
678// cancellable,
679// …,
680// &local_error);
681//
682// // Process the returned files, but don’t assume that exactly 5 were returned.
683// for (GList *l = files; l != NULL; l = l->next)
684// {
685// GFileInfo *info = l->data;
686// handle_file_info (info);
687// }
688// }
689//
690// while (files != NULL);
691//
692// if (local_error != NULL &&
693//
694// !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
695// g_error ("Error while enumerating: %s", local_error->message);
696//
697// ]|
698//
699// During an async request no other sync and async calls are allowed, and will
700// result in %G_IO_ERROR_PENDING errors.
701//
702// Any outstanding I/O request with higher priority (lower numerical value) will
703// be executed before an outstanding request with lower priority. Default
704// priority is %G_PRIORITY_DEFAULT.
705func (x *FileEnumerator) NextFilesAsync(NumFilesVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
706
707 var CallbackVarRef uintptr
708 if CallbackVar != nil {
709 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
710 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
711 CallbackVarRef = cbRefPtr
712 } else {
713 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
714 cbFn := *CallbackVar
715 cbFn(arg0, arg1, arg2)
716 }
717 CallbackVarRef = purego.NewCallback(fcb)
718 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
719 }
720 }
721
722 xFileEnumeratorNextFilesAsync(x.GoPointer(), NumFilesVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
723
724}
725
726var xFileEnumeratorNextFilesFinish func(uintptr, uintptr, **glib.Error) *glib.List
727
728// Finishes the asynchronous operation started with g_file_enumerator_next_files_async().
729func (x *FileEnumerator) NextFilesFinish(ResultVar AsyncResult) (*glib.List, error) {
730 var cerr *glib.Error
731
732 cret := xFileEnumeratorNextFilesFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
733 if cerr == nil {
734 return cret, nil
735 }
736 return cret, cerr
737
738}
739
740var xFileEnumeratorSetPending func(uintptr, bool)
741
742// Sets the file enumerator as having pending operations.
743func (x *FileEnumerator) SetPending(PendingVar bool) {
744
745 xFileEnumeratorSetPending(x.GoPointer(), PendingVar)
746
747}
748
749func (c *FileEnumerator) GoPointer() uintptr {
750 if c == nil {
751 return 0
752 }
753 return c.Ptr
754}
755
756func (c *FileEnumerator) SetGoPointer(ptr uintptr) {
757 c.Ptr = ptr
758}
759
760func init() {
761 core.SetPackageName("GIO", "gio-2.0")
762 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
763 var libs []uintptr
764 for _, libPath := range core.GetPaths("GIO") {
765 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
766 if err != nil {
767 panic(err)
768 }
769 libs = append(libs, lib)
770 }
771
772 core.PuregoSafeRegister(&xFileEnumeratorGLibType, libs, "g_file_enumerator_get_type")
773
774 core.PuregoSafeRegister(&xFileEnumeratorClose, libs, "g_file_enumerator_close")
775 core.PuregoSafeRegister(&xFileEnumeratorCloseAsync, libs, "g_file_enumerator_close_async")
776 core.PuregoSafeRegister(&xFileEnumeratorCloseFinish, libs, "g_file_enumerator_close_finish")
777 core.PuregoSafeRegister(&xFileEnumeratorGetChild, libs, "g_file_enumerator_get_child")
778 core.PuregoSafeRegister(&xFileEnumeratorGetContainer, libs, "g_file_enumerator_get_container")
779 core.PuregoSafeRegister(&xFileEnumeratorHasPending, libs, "g_file_enumerator_has_pending")
780 core.PuregoSafeRegister(&xFileEnumeratorIsClosed, libs, "g_file_enumerator_is_closed")
781 core.PuregoSafeRegister(&xFileEnumeratorIterate, libs, "g_file_enumerator_iterate")
782 core.PuregoSafeRegister(&xFileEnumeratorNextFile, libs, "g_file_enumerator_next_file")
783 core.PuregoSafeRegister(&xFileEnumeratorNextFilesAsync, libs, "g_file_enumerator_next_files_async")
784 core.PuregoSafeRegister(&xFileEnumeratorNextFilesFinish, libs, "g_file_enumerator_next_files_finish")
785 core.PuregoSafeRegister(&xFileEnumeratorSetPending, libs, "g_file_enumerator_set_pending")
786
787}