Gjsify LogoGjsify Logo

The #GMappedFile represents a file mapping created with g_mapped_file_new(). It has only private members and should not be accessed directly.

record

Hierarchy

  • MappedFile

Index

Constructors

  • new MappedFile(filename: string, writable: boolean): MappedFile
  • 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 #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.

    Parameters

    • filename: string

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

    • writable: boolean

      whether the mapping should be writable

    Returns MappedFile

Properties

name: string

Methods

  • free(): void
  • This call existed before #GMappedFile had refcounting and is currently exactly the same as g_mapped_file_unref().

    Returns void

  • getBytes(): any
  • 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.

    Returns any

  • getContents(): string
  • 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.

    Returns string

  • getLength(): number
  • Returns the length of the contents of a #GMappedFile.

    Returns number

  • Increments the reference count of file by one. It is safe to call this function from any thread.

    Returns MappedFile

  • unref(): void
  • 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

    Returns void

  • new(filename: string, writable: boolean): MappedFile
  • 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 #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.

    Parameters

    • filename: string

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

    • writable: boolean

      whether the mapping should be writable

    Returns MappedFile

  • newFromFd(fd: number, writable: boolean): MappedFile
  • 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 #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()).

    Parameters

    • fd: number

      The file descriptor of the file to load

    • writable: boolean

      whether the mapping should be writable

    Returns MappedFile

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method