GLib.MappedFile.new

function new(filename: String, writable: Boolean): GLib.MappedFile {
    // Gjs wrapper for g_mapped_file_new()
}
  

Maps a file into memory. On UNIX, this is using the mmap() function.

If writable 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 GLib.MappedFile. 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 GLib.file_set_contents).

If filename is the name of an empty, regular file, the function will successfully return an empty GLib.MappedFile. In other cases of size 0 (e.g. device files such as /dev/null), @error will be set to the GLib.FileError value #G_FILE_ERROR_INVAL.

Since 2.8

filename

The path of the file to load, in the GLib filename encoding

writable

whether the mapping should be writable

Returns

a newly allocated GLib.MappedFile which must be unref'd with GLib.MappedFile.prototype.unref, or null if the mapping failed.