Basics
Guides
API Reference
Basics
Guides
API Reference
[13:7] extends: object
The #GMappedFile represents a file mapping created with g_mapped_file_new(). It has only private members and should not be accessed directly.
GMappedFile (filename = null, writable = null)
Maps a file into memory. On UNIX, this is using the mmap() function. If
is %TRUE, the mapped buffer may be modified, otherwise it is an error to modify the mapped buffer. Modifications to the buffer are not visible to other processes mapping the same file, and are not written back to the file. Note that modifications of the underlying file might affect the contents of the #GMappedFile. Therefore, mapping should only be used if the file will not be modified, or if all modifications of the file are done atomically (e.g. using g_file_set_contents()). If @filename is the name of an empty, regular file, the function will successfully return an empty #GMappedFile. In other cases of size 0 (e.g. device files such as /dev/null), @error will be set to the #GFileError value %G_FILE_ERROR_INVAL.filename is The path of the file to load, in the GLib filename encoding.writable is whether the mapping should be writable.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.free ()
This call existed before #GMappedFile had refcounting and is currently exactly the same as g_mapped_file_unref().
None.get_bytes ()
Creates a new #GBytes which references the data mapped from @file. The mapped contents of the file must not be modified after creating this bytes object, because a #GBytes should be immutable.
A newly allocated #GBytes referencing data from @file.get_contents ()
Returns the contents of a #GMappedFile. Note that the contents may not be zero-terminated, even if the #GMappedFile is backed by a text file. If the file is empty then %NULL is returned.
the contents of @file, or %NULL..get_length ()
Returns the length of the contents of a #GMappedFile.
the length of the contents of @file..ref ()
Increments the reference count of @file by one. It is safe to call this function from any thread.
the passed in #GMappedFile..unref ()
Decrements the reference count of @file by one. If the reference count drops to 0, unmaps the buffer of @file and frees it. It is safe to call this function from any thread. Since 2.22
None.[188:14] static extends: object
Alternate constructors for GMappedFile. Usage:
GMappedFileCtors.<name>(...). The primary constructor lives
directly on GMappedFile.
newFromFd (int fd, bool writable)
Maps a file into memory. On UNIX, this is using the mmap() function. If
is %TRUE, the mapped buffer may be modified, otherwise it is an error to modify the mapped buffer. Modifications to the buffer are not visible to other processes mapping the same file, and are not written back to the file. Note that modifications of the underlying file might affect the contents of the #GMappedFile. Therefore, mapping should only be used if the file will not be modified, or if all modifications of the file are done atomically (e.g. using g_file_set_contents()).fd is The file descriptor of the file to load.writable is whether the mapping should be writable.A new GMappedFile.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.