// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject/types" ) type FileIOStreamClass struct { _ structs.HostLayout ParentClass IOStreamClass xTell uintptr xCanSeek uintptr xSeek uintptr xCanTruncate uintptr xTruncateFn uintptr xQueryInfo uintptr xQueryInfoAsync uintptr xQueryInfoFinish uintptr xGetEtag uintptr xGReserved1 uintptr xGReserved2 uintptr xGReserved3 uintptr xGReserved4 uintptr xGReserved5 uintptr } func (x *FileIOStreamClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideTell sets the "tell" callback function. func (x *FileIOStreamClass) OverrideTell(cb func(*FileIOStream) int64) { if cb == nil { x.xTell = 0 } else { x.xTell = purego.NewCallback(func(StreamVarp uintptr) int64 { return cb(FileIOStreamNewFromInternalPtr(StreamVarp)) }) } } // GetTell gets the "tell" callback function. func (x *FileIOStreamClass) GetTell() func(*FileIOStream) int64 { if x.xTell == 0 { return nil } var rawCallback func(StreamVarp uintptr) int64 purego.RegisterFunc(&rawCallback, x.xTell) return func(StreamVar *FileIOStream) int64 { return rawCallback(StreamVar.GoPointer()) } } // OverrideCanSeek sets the "can_seek" callback function. func (x *FileIOStreamClass) OverrideCanSeek(cb func(*FileIOStream) bool) { if cb == nil { x.xCanSeek = 0 } else { x.xCanSeek = purego.NewCallback(func(StreamVarp uintptr) bool { return cb(FileIOStreamNewFromInternalPtr(StreamVarp)) }) } } // GetCanSeek gets the "can_seek" callback function. func (x *FileIOStreamClass) GetCanSeek() func(*FileIOStream) bool { if x.xCanSeek == 0 { return nil } var rawCallback func(StreamVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xCanSeek) return func(StreamVar *FileIOStream) bool { return rawCallback(StreamVar.GoPointer()) } } // OverrideSeek sets the "seek" callback function. func (x *FileIOStreamClass) OverrideSeek(cb func(*FileIOStream, int64, glib.SeekType, *Cancellable) bool) { if cb == nil { x.xSeek = 0 } else { x.xSeek = purego.NewCallback(func(StreamVarp uintptr, OffsetVarp int64, TypeVarp glib.SeekType, CancellableVarp uintptr) bool { return cb(FileIOStreamNewFromInternalPtr(StreamVarp), OffsetVarp, TypeVarp, CancellableNewFromInternalPtr(CancellableVarp)) }) } } // GetSeek gets the "seek" callback function. func (x *FileIOStreamClass) GetSeek() func(*FileIOStream, int64, glib.SeekType, *Cancellable) bool { if x.xSeek == 0 { return nil } var rawCallback func(StreamVarp uintptr, OffsetVarp int64, TypeVarp glib.SeekType, CancellableVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xSeek) return func(StreamVar *FileIOStream, OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) bool { return rawCallback(StreamVar.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer()) } } // OverrideCanTruncate sets the "can_truncate" callback function. func (x *FileIOStreamClass) OverrideCanTruncate(cb func(*FileIOStream) bool) { if cb == nil { x.xCanTruncate = 0 } else { x.xCanTruncate = purego.NewCallback(func(StreamVarp uintptr) bool { return cb(FileIOStreamNewFromInternalPtr(StreamVarp)) }) } } // GetCanTruncate gets the "can_truncate" callback function. func (x *FileIOStreamClass) GetCanTruncate() func(*FileIOStream) bool { if x.xCanTruncate == 0 { return nil } var rawCallback func(StreamVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xCanTruncate) return func(StreamVar *FileIOStream) bool { return rawCallback(StreamVar.GoPointer()) } } // OverrideTruncateFn sets the "truncate_fn" callback function. func (x *FileIOStreamClass) OverrideTruncateFn(cb func(*FileIOStream, int64, *Cancellable) bool) { if cb == nil { x.xTruncateFn = 0 } else { x.xTruncateFn = purego.NewCallback(func(StreamVarp uintptr, SizeVarp int64, CancellableVarp uintptr) bool { return cb(FileIOStreamNewFromInternalPtr(StreamVarp), SizeVarp, CancellableNewFromInternalPtr(CancellableVarp)) }) } } // GetTruncateFn gets the "truncate_fn" callback function. func (x *FileIOStreamClass) GetTruncateFn() func(*FileIOStream, int64, *Cancellable) bool { if x.xTruncateFn == 0 { return nil } var rawCallback func(StreamVarp uintptr, SizeVarp int64, CancellableVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xTruncateFn) return func(StreamVar *FileIOStream, SizeVar int64, CancellableVar *Cancellable) bool { return rawCallback(StreamVar.GoPointer(), SizeVar, CancellableVar.GoPointer()) } } // OverrideQueryInfo sets the "query_info" callback function. func (x *FileIOStreamClass) OverrideQueryInfo(cb func(*FileIOStream, string, *Cancellable) *FileInfo) { if cb == nil { x.xQueryInfo = 0 } else { x.xQueryInfo = purego.NewCallback(func(StreamVarp uintptr, AttributesVarp string, CancellableVarp uintptr) uintptr { ret := cb(FileIOStreamNewFromInternalPtr(StreamVarp), AttributesVarp, CancellableNewFromInternalPtr(CancellableVarp)) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetQueryInfo gets the "query_info" callback function. func (x *FileIOStreamClass) GetQueryInfo() func(*FileIOStream, string, *Cancellable) *FileInfo { if x.xQueryInfo == 0 { return nil } var rawCallback func(StreamVarp uintptr, AttributesVarp string, CancellableVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xQueryInfo) return func(StreamVar *FileIOStream, AttributesVar string, CancellableVar *Cancellable) *FileInfo { rawRet := rawCallback(StreamVar.GoPointer(), AttributesVar, CancellableVar.GoPointer()) if rawRet == 0 { return nil } ret := &FileInfo{} ret.Ptr = rawRet return ret } } // OverrideQueryInfoAsync sets the "query_info_async" callback function. func (x *FileIOStreamClass) OverrideQueryInfoAsync(cb func(*FileIOStream, string, int, *Cancellable, *AsyncReadyCallback, uintptr)) { if cb == nil { x.xQueryInfoAsync = 0 } else { x.xQueryInfoAsync = purego.NewCallback(func(StreamVarp uintptr, AttributesVarp string, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) { cb(FileIOStreamNewFromInternalPtr(StreamVarp), AttributesVarp, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp) }) } } // GetQueryInfoAsync gets the "query_info_async" callback function. func (x *FileIOStreamClass) GetQueryInfoAsync() func(*FileIOStream, string, int, *Cancellable, *AsyncReadyCallback, uintptr) { if x.xQueryInfoAsync == 0 { return nil } var rawCallback func(StreamVarp uintptr, AttributesVarp string, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) purego.RegisterFunc(&rawCallback, x.xQueryInfoAsync) return func(StreamVar *FileIOStream, AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { rawCallback(StreamVar.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar) } } // OverrideQueryInfoFinish sets the "query_info_finish" callback function. func (x *FileIOStreamClass) OverrideQueryInfoFinish(cb func(*FileIOStream, AsyncResult) *FileInfo) { if cb == nil { x.xQueryInfoFinish = 0 } else { x.xQueryInfoFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr) uintptr { ret := cb(FileIOStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetQueryInfoFinish gets the "query_info_finish" callback function. func (x *FileIOStreamClass) GetQueryInfoFinish() func(*FileIOStream, AsyncResult) *FileInfo { if x.xQueryInfoFinish == 0 { return nil } var rawCallback func(StreamVarp uintptr, ResultVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xQueryInfoFinish) return func(StreamVar *FileIOStream, ResultVar AsyncResult) *FileInfo { rawRet := rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer()) if rawRet == 0 { return nil } ret := &FileInfo{} ret.Ptr = rawRet return ret } } // OverrideGetEtag sets the "get_etag" callback function. func (x *FileIOStreamClass) OverrideGetEtag(cb func(*FileIOStream) string) { if cb == nil { x.xGetEtag = 0 } else { x.xGetEtag = purego.NewCallback(func(StreamVarp uintptr) string { return cb(FileIOStreamNewFromInternalPtr(StreamVarp)) }) } } // GetGetEtag gets the "get_etag" callback function. func (x *FileIOStreamClass) GetGetEtag() func(*FileIOStream) string { if x.xGetEtag == 0 { return nil } var rawCallback func(StreamVarp uintptr) string purego.RegisterFunc(&rawCallback, x.xGetEtag) return func(StreamVar *FileIOStream) string { return rawCallback(StreamVar.GoPointer()) } } // OverrideGReserved1 sets the "_g_reserved1" callback function. func (x *FileIOStreamClass) OverrideGReserved1(cb func()) { if cb == nil { x.xGReserved1 = 0 } else { x.xGReserved1 = purego.NewCallback(func() { cb() }) } } // GetGReserved1 gets the "_g_reserved1" callback function. func (x *FileIOStreamClass) GetGReserved1() func() { if x.xGReserved1 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved1) return func() { rawCallback() } } // OverrideGReserved2 sets the "_g_reserved2" callback function. func (x *FileIOStreamClass) OverrideGReserved2(cb func()) { if cb == nil { x.xGReserved2 = 0 } else { x.xGReserved2 = purego.NewCallback(func() { cb() }) } } // GetGReserved2 gets the "_g_reserved2" callback function. func (x *FileIOStreamClass) GetGReserved2() func() { if x.xGReserved2 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved2) return func() { rawCallback() } } // OverrideGReserved3 sets the "_g_reserved3" callback function. func (x *FileIOStreamClass) OverrideGReserved3(cb func()) { if cb == nil { x.xGReserved3 = 0 } else { x.xGReserved3 = purego.NewCallback(func() { cb() }) } } // GetGReserved3 gets the "_g_reserved3" callback function. func (x *FileIOStreamClass) GetGReserved3() func() { if x.xGReserved3 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved3) return func() { rawCallback() } } // OverrideGReserved4 sets the "_g_reserved4" callback function. func (x *FileIOStreamClass) OverrideGReserved4(cb func()) { if cb == nil { x.xGReserved4 = 0 } else { x.xGReserved4 = purego.NewCallback(func() { cb() }) } } // GetGReserved4 gets the "_g_reserved4" callback function. func (x *FileIOStreamClass) GetGReserved4() func() { if x.xGReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved4) return func() { rawCallback() } } // OverrideGReserved5 sets the "_g_reserved5" callback function. func (x *FileIOStreamClass) OverrideGReserved5(cb func()) { if cb == nil { x.xGReserved5 = 0 } else { x.xGReserved5 = purego.NewCallback(func() { cb() }) } } // GetGReserved5 gets the "_g_reserved5" callback function. func (x *FileIOStreamClass) GetGReserved5() func() { if x.xGReserved5 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved5) return func() { rawCallback() } } type FileIOStreamPrivate struct { _ structs.HostLayout } func (x *FileIOStreamPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // `GFileIOStream` provides I/O streams that both read and write to the same // file handle. // // `GFileIOStream` implements [iface@Gio.Seekable], which allows the I/O // stream to jump to arbitrary positions in the file and to truncate // the file, provided the filesystem of the file supports these // operations. // // To find the position of a file I/O stream, use [method@Gio.Seekable.tell]. // // To find out if a file I/O stream supports seeking, use // [method@Gio.Seekable.can_seek]. To position a file I/O stream, use // [method@Gio.Seekable.seek]. To find out if a file I/O stream supports // truncating, use [method@Gio.Seekable.can_truncate]. To truncate a file I/O // stream, use [method@Gio.Seekable.truncate]. // // The default implementation of all the `GFileIOStream` operations // and the implementation of [iface@Gio.Seekable] just call into the same // operations on the output stream. type FileIOStream struct { IOStream } var xFileIOStreamGLibType func() types.GType func FileIOStreamGLibType() types.GType { return xFileIOStreamGLibType() } func FileIOStreamNewFromInternalPtr(ptr uintptr) *FileIOStream { cls := &FileIOStream{} cls.Ptr = ptr return cls } var xFileIOStreamGetEtag func(uintptr) string // Gets the entity tag for the file when it has been written. // This must be called after the stream has been written // and closed, as the etag can change while writing. func (x *FileIOStream) GetEtag() string { cret := xFileIOStreamGetEtag(x.GoPointer()) return cret } var xFileIOStreamQueryInfo func(uintptr, string, uintptr, **glib.Error) uintptr // Queries a file io stream for the given @attributes. // This function blocks while querying the stream. For the asynchronous // version of this function, see g_file_io_stream_query_info_async(). // While the stream is blocked, the stream will set the pending flag // internally, and any other operations on the stream will fail with // %G_IO_ERROR_PENDING. // // Can fail if the stream was already closed (with @error being set to // %G_IO_ERROR_CLOSED), the stream has pending operations (with @error being // set to %G_IO_ERROR_PENDING), or if querying info is not supported for // the stream's interface (with @error being set to %G_IO_ERROR_NOT_SUPPORTED). I // all cases of failure, %NULL will be returned. // // If @cancellable is not %NULL, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error %G_IO_ERROR_CANCELLED will be set, and %NULL will // be returned. func (x *FileIOStream) QueryInfo(AttributesVar string, CancellableVar *Cancellable) (*FileInfo, error) { var cls *FileInfo var cerr *glib.Error cret := xFileIOStreamQueryInfo(x.GoPointer(), AttributesVar, CancellableVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &FileInfo{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xFileIOStreamQueryInfoAsync func(uintptr, string, int, uintptr, uintptr, uintptr) // Asynchronously queries the @stream for a #GFileInfo. When completed, // @callback will be called with a #GAsyncResult which can be used to // finish the operation with g_file_io_stream_query_info_finish(). // // For the synchronous version of this function, see // g_file_io_stream_query_info(). func (x *FileIOStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xFileIOStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xFileIOStreamQueryInfoFinish func(uintptr, uintptr, **glib.Error) uintptr // Finalizes the asynchronous query started // by g_file_io_stream_query_info_async(). func (x *FileIOStream) QueryInfoFinish(ResultVar AsyncResult) (*FileInfo, error) { var cls *FileInfo var cerr *glib.Error cret := xFileIOStreamQueryInfoFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &FileInfo{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } func (c *FileIOStream) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *FileIOStream) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Tests if the stream supports the #GSeekableIface. func (x *FileIOStream) CanSeek() bool { cret := XGSeekableCanSeek(x.GoPointer()) return cret } // Tests if the length of the stream can be adjusted with // g_seekable_truncate(). func (x *FileIOStream) CanTruncate() bool { cret := XGSeekableCanTruncate(x.GoPointer()) return cret } // Seeks in the stream by the given @offset, modified by @type. // // Attempting to seek past the end of the stream will have different // results depending on if the stream is fixed-sized or resizable. If // the stream is resizable then seeking past the end and then writing // will result in zeros filling the empty space. Seeking past the end // of a resizable stream and reading will result in EOF. Seeking past // the end of a fixed-sized stream will fail. // // Any operation that would result in a negative offset will fail. // // If @cancellable is not %NULL, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. func (x *FileIOStream) Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error) { var cerr *glib.Error cret := XGSeekableSeek(x.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } // Tells the current position within the stream. func (x *FileIOStream) Tell() int64 { cret := XGSeekableTell(x.GoPointer()) return cret } // Sets the length of the stream to @offset. If the stream was previously // larger than @offset, the extra data is discarded. If the stream was // previously shorter than @offset, it is extended with NUL ('\0') bytes. // // If @cancellable is not %NULL, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an // operation was partially finished when the operation was cancelled the // partial result will be returned, without an error. func (x *FileIOStream) Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error) { var cerr *glib.Error cret := XGSeekableTruncate(x.GoPointer(), OffsetVar, CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } func init() { core.SetPackageName("GIO", "gio-2.0") core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GIO") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xFileIOStreamGLibType, libs, "g_file_io_stream_get_type") core.PuregoSafeRegister(&xFileIOStreamGetEtag, libs, "g_file_io_stream_get_etag") core.PuregoSafeRegister(&xFileIOStreamQueryInfo, libs, "g_file_io_stream_query_info") core.PuregoSafeRegister(&xFileIOStreamQueryInfoAsync, libs, "g_file_io_stream_query_info_async") core.PuregoSafeRegister(&xFileIOStreamQueryInfoFinish, libs, "g_file_io_stream_query_info_finish") }