Basics
Guides
API Reference
Basics
Guides
API Reference
[12:7] extends: object
An opaque structure representing an opened directory.
GDir (path = null, flags = null)
Opens a directory for reading. The names of the files in the directory can then be retrieved using g_dir_read_name(). Note that the ordering is not defined.
path is the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8.flags is Currently must be set to 0. Reserved for future use..toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.close ()
Closes the directory immediately and decrements the reference count. Once the reference count reaches zero, the
GDirstructure itself will be freed. Prior to GLib 2.80,GDirwas not reference counted. It is an error to call any of theGDirmethods other than [method@GLib.Dir.ref] and [method@GLib.Dir.unref] on aGDirafter calling [method@GLib.Dir.close] on it.
None.read_name ()
Retrieves the name of another entry in the directory, or %NULL. The order of entries returned from this function is not defined, and may vary by file system or other operating-system dependent factors. %NULL may also be returned in case of errors. On Unix, you can check
errnoto find out if %NULL was returned because of an error. On Unix, the '.' and '..' entries are omitted, and the returned name is in the on-disk encoding. On Windows, as is true of all GLib functions which operate on filenames, the returned name is in UTF-8.
The entry's name or %NULL if there are no more entries. The return value is owned by GLib and must not be modified or freed..ref ()
Increment the reference count of
dir.
the same pointer as dir.rewind ()
Resets the given directory. The next call to g_dir_read_name() will return the first entry again.
None.unref ()
Decrements the reference count of
dir. Once the reference count reaches zero, the directory will be closed and all resources associated with it will be freed. If [method@GLib.Dir.close] is called when the reference count is greater than zero, the directory is closed but theGDirstructure will not be freed until its reference count reaches zero. It is an error to call any of theGDirmethods other than [method@GLib.Dir.ref] and [method@GLib.Dir.unref] on aGDirafter calling [method@GLib.Dir.close] on it.
None.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.