Gjsify LogoGjsify Logo

Index

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

DateDay: number
DateYear: number
MainContextPusher: void
MutexLocker: void
Pid: number
Quark: number
RWLockReaderLocker: void
RWLockWriterLocker: void
RecMutexLocker: void
RefString: number
Strv: string
Time: number
TimeSpan: number
Type: number

Variables

ANALYZER_ANALYZING: number
ASCII_DTOSTR_BUF_SIZE: number

A good size for a buffer to be passed into g_ascii_dtostr(). It is guaranteed to be enough for all output of that function on systems with 64bit IEEE-compatible doubles.

The typical usage would be something like:

  char buf[G_ASCII_DTOSTR_BUF_SIZE];

fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
BIG_ENDIAN: number

Specifies one of the possible types of byte order. See %G_BYTE_ORDER.

CSET_A_2_Z: string

The set of uppercase ASCII alphabet characters. Used for specifying valid identifier characters in #GScannerConfig.

CSET_DIGITS: string

The set of ASCII digits. Used for specifying valid identifier characters in #GScannerConfig.

CSET_a_2_z: string

The set of lowercase ASCII alphabet characters. Used for specifying valid identifier characters in #GScannerConfig.

DATALIST_FLAGS_MASK: number

A bitmask that restricts the possible flags passed to g_datalist_set_flags(). Passing a flags value where flags & ~G_DATALIST_FLAGS_MASK != 0 is an error.

DATE_BAD_DAY: number

Represents an invalid #GDateDay.

DATE_BAD_JULIAN: number

Represents an invalid Julian day number.

DATE_BAD_YEAR: number

Represents an invalid year.

DIR_SEPARATOR: number

The directory separator character. This is '/' on UNIX machines and '' under Windows.

DIR_SEPARATOR_S: string

The directory separator as a string. This is "/" on UNIX machines and "" under Windows.

E: number

The base of natural logarithms.

GINT16_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #gint16. It is a string literal, but doesn't include the percent-sign, such that you can add precision and length modifiers between percent-sign and conversion specifier.

gint16 in;
gint32 out;
sscanf ("42", "%" G_GINT16_FORMAT, &in)
out = in * 1000;
g_print ("%" G_GINT32_FORMAT, out);
GINT16_MODIFIER: string

The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gint16 or #guint16. It is a string literal, but doesn't include the percent-sign, such that you can add precision and length modifiers between percent-sign and conversion specifier and append a conversion specifier.

The following example prints "0x7b";

gint16 value = 123;
g_print ("%#" G_GINT16_MODIFIER "x", value);
GINT32_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #gint32. See also %G_GINT16_FORMAT.

GINT32_MODIFIER: string

The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gint32 or #guint32. It is a string literal. See also %G_GINT16_MODIFIER.

GINT64_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #gint64. See also %G_GINT16_FORMAT.

Some platforms do not support scanning and printing 64-bit integers, even though the types are supported. On such platforms %G_GINT64_FORMAT is not defined. Note that scanf() may not support 64-bit integers, even if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf() is not recommended for parsing anyway; consider using g_ascii_strtoull() instead.

GINT64_MODIFIER: string

The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gint64 or #guint64. It is a string literal.

Some platforms do not support printing 64-bit integers, even though the types are supported. On such platforms %G_GINT64_MODIFIER is not defined.

GINTPTR_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #gintptr.

GINTPTR_MODIFIER: string

The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gintptr or #guintptr. It is a string literal.

GNUC_FUNCTION: string

Expands to "" on all modern compilers, and to FUNCTION on gcc version 2.x. Don't use it.

GNUC_PRETTY_FUNCTION: string

Expands to "" on all modern compilers, and to PRETTY_FUNCTION on gcc version 2.x. Don't use it.

GSIZE_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #gsize. See also %G_GINT16_FORMAT.

GSIZE_MODIFIER: string

The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gsize. It is a string literal.

GSSIZE_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #gssize. See also %G_GINT16_FORMAT.

GSSIZE_MODIFIER: string

The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gssize. It is a string literal.

GUINT16_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #guint16. See also %G_GINT16_FORMAT

GUINT32_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #guint32. See also %G_GINT16_FORMAT.

GUINT64_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #guint64. See also %G_GINT16_FORMAT.

Some platforms do not support scanning and printing 64-bit integers, even though the types are supported. On such platforms %G_GUINT64_FORMAT is not defined. Note that scanf() may not support 64-bit integers, even if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf() is not recommended for parsing anyway; consider using g_ascii_strtoull() instead.

GUINTPTR_FORMAT: string

This is the platform dependent conversion specifier for scanning and printing values of type #guintptr.

HAVE_GINT64: number
HAVE_GNUC_VARARGS: number
HAVE_GNUC_VISIBILITY: number

Defined to 1 if gcc-style visibility handling is supported.

HAVE_GROWING_STACK: number
HAVE_ISO_VARARGS: number
HOOK_FLAG_USER_SHIFT: number

The position of the first bit which is not reserved for internal use be the #GHook implementation, i.e. 1 << G_HOOK_FLAG_USER_SHIFT is the first bit which can be used for application-defined flags.

IEEE754_DOUBLE_BIAS: number

The bias by which exponents in double-precision floats are offset.

IEEE754_FLOAT_BIAS: number

The bias by which exponents in single-precision floats are offset.

KEY_FILE_DESKTOP_GROUP: string

The name of the main group of a desktop entry file, as defined in the Desktop Entry Specification. Consult the specification for more details about the meanings of the keys below.

KEY_FILE_DESKTOP_KEY_ACTIONS: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string list giving the available application actions.

KEY_FILE_DESKTOP_KEY_CATEGORIES: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list of strings giving the categories in which the desktop entry should be shown in a menu.

KEY_FILE_DESKTOP_KEY_COMMENT: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized string giving the tooltip for the desktop entry.

KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean set to true if the application is D-Bus activatable.

KEY_FILE_DESKTOP_KEY_EXEC: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string giving the command line to execute. It is only valid for desktop entries with the Application type.

KEY_FILE_DESKTOP_KEY_GENERIC_NAME: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized string giving the generic name of the desktop entry.

KEY_FILE_DESKTOP_KEY_HIDDEN: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean stating whether the desktop entry has been deleted by the user.

KEY_FILE_DESKTOP_KEY_ICON: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized string giving the name of the icon to be displayed for the desktop entry.

KEY_FILE_DESKTOP_KEY_MIME_TYPE: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list of strings giving the MIME types supported by this desktop entry.

KEY_FILE_DESKTOP_KEY_NAME: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized string giving the specific name of the desktop entry.

KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list of strings identifying the environments that should not display the desktop entry.

KEY_FILE_DESKTOP_KEY_NO_DISPLAY: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean stating whether the desktop entry should be shown in menus.

KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list of strings identifying the environments that should display the desktop entry.

KEY_FILE_DESKTOP_KEY_PATH: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string containing the working directory to run the program in. It is only valid for desktop entries with the Application type.

KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean stating whether the application supports the Startup Notification Protocol Specification.

KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is string identifying the WM class or name hint of a window that the application will create, which can be used to emulate Startup Notification with older applications.

KEY_FILE_DESKTOP_KEY_TERMINAL: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean stating whether the program should be run in a terminal window.

It is only valid for desktop entries with the Application type.

KEY_FILE_DESKTOP_KEY_TRY_EXEC: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string giving the file name of a binary on disk used to determine if the program is actually installed. It is only valid for desktop entries with the Application type.

KEY_FILE_DESKTOP_KEY_TYPE: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string giving the type of the desktop entry.

Usually %G_KEY_FILE_DESKTOP_TYPE_APPLICATION, %G_KEY_FILE_DESKTOP_TYPE_LINK, or %G_KEY_FILE_DESKTOP_TYPE_DIRECTORY.

KEY_FILE_DESKTOP_KEY_URL: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string giving the URL to access. It is only valid for desktop entries with the Link type.

KEY_FILE_DESKTOP_KEY_VERSION: string

A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string giving the version of the Desktop Entry Specification used for the desktop entry file.

KEY_FILE_DESKTOP_TYPE_APPLICATION: string

The value of the %G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop entries representing applications.

KEY_FILE_DESKTOP_TYPE_DIRECTORY: string

The value of the %G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop entries representing directories.

KEY_FILE_DESKTOP_TYPE_LINK: string

The value of the %G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop entries representing links to documents.

LITTLE_ENDIAN: number

Specifies one of the possible types of byte order. See %G_BYTE_ORDER.

LN10: number

The natural logarithm of 10.

LN2: number

The natural logarithm of 2.

LOG_2_BASE_10: number

Multiplying the base 2 exponent by this number yields the base 10 exponent.

LOG_DOMAIN: number

Defines the log domain. See Log Domains.

Libraries should define this so that any messages which they log can be differentiated from messages from other libraries and application code. But be careful not to define it in any public header files.

Log domains must be unique, and it is recommended that they are the application or library name, optionally followed by a hyphen and a sub-domain name. For example, bloatpad or bloatpad-io.

If undefined, it defaults to the default %NULL (or "") log domain; this is not advisable, as it cannot be filtered against using the G_MESSAGES_DEBUG environment variable.

For example, GTK+ uses this in its Makefile.am: |[ AM_CPPFLAGS = -DG_LOG_DOMAIN="Gtk"



Applications can choose to leave it as the default %NULL (or `""`)
domain. However, defining the domain offers the same advantages as
above.
LOG_FATAL_MASK: number

GLib log levels that are considered fatal by default.

This is not used if structured logging is enabled; see [Using Structured Logging][using-structured-logging].

LOG_LEVEL_USER_SHIFT: number

Log levels below 1<<G_LOG_LEVEL_USER_SHIFT are used by GLib. Higher bits can be used for user-defined log levels.

MAJOR_VERSION: number

The major version number of the GLib library.

Like #glib_major_version, but from the headers used at application compile time, rather than from the library linked against at application run time.

MAXINT16: number

The maximum value which can be held in a #gint16.

MAXINT32: number

The maximum value which can be held in a #gint32.

MAXINT64: number

The maximum value which can be held in a #gint64.

MAXINT8: number

The maximum value which can be held in a #gint8.

MAXUINT16: number

The maximum value which can be held in a #guint16.

MAXUINT32: number

The maximum value which can be held in a #guint32.

MAXUINT64: number

The maximum value which can be held in a #guint64.

MAXUINT8: number

The maximum value which can be held in a #guint8.

MICRO_VERSION: number

The micro version number of the GLib library.

Like #gtk_micro_version, but from the headers used at application compile time, rather than from the library linked against at application run time.

MININT16: number

The minimum value which can be held in a #gint16.

MININT32: number

The minimum value which can be held in a #gint32.

MININT64: number

The minimum value which can be held in a #gint64.

MININT8: number

The minimum value which can be held in a #gint8.

MINOR_VERSION: number

The minor version number of the GLib library.

Like #gtk_minor_version, but from the headers used at application compile time, rather than from the library linked against at application run time.

MODULE_SUFFIX: string
OPTION_REMAINING: string

If a long option in the main group has this name, it is not treated as a regular option. Instead it collects all non-option arguments which would otherwise be left in argv. The option must be of type %G_OPTION_ARG_CALLBACK, %G_OPTION_ARG_STRING_ARRAY or %G_OPTION_ARG_FILENAME_ARRAY.

Using %G_OPTION_REMAINING instead of simply scanning argv for leftover arguments has the advantage that GOption takes care of necessary encoding conversions for strings or filenames.

PDP_ENDIAN: number

Specifies one of the possible types of byte order (currently unused). See %G_BYTE_ORDER.

PI: number

The value of pi (ratio of circle's circumference to its diameter).

PID_FORMAT: string

A format specifier that can be used in printf()-style format strings when printing a #GPid.

PI_2: number

Pi divided by 2.

PI_4: number

Pi divided by 4.

POLLFD_FORMAT: string

A format specifier that can be used in printf()-style format strings when printing the fd member of a #GPollFD.

PRIORITY_DEFAULT: number

Use this for default priority event sources.

In GLib this priority is used when adding timeout functions with g_timeout_add(). In GDK this priority is used for events from the X server.

PRIORITY_DEFAULT_IDLE: number

Use this for default priority idle functions.

In GLib this priority is used when adding idle functions with g_idle_add().

PRIORITY_HIGH: number

Use this for high priority event sources.

It is not used within GLib or GTK+.

PRIORITY_HIGH_IDLE: number

Use this for high priority idle functions.

GTK+ uses %G_PRIORITY_HIGH_IDLE + 10 for resizing operations, and %G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is done to ensure that any pending resizes are processed before any pending redraws, so that widgets are not redrawn twice unnecessarily.)

PRIORITY_LOW: number

Use this for very low priority background tasks.

It is not used within GLib or GTK+.

SEARCHPATH_SEPARATOR: number

The search path separator character. This is ':' on UNIX machines and ';' under Windows.

SEARCHPATH_SEPARATOR_S: string

The search path separator as a string. This is ":" on UNIX machines and ";" under Windows.

SIZEOF_LONG: number
SIZEOF_SIZE_T: number
SIZEOF_SSIZE_T: number
SIZEOF_VOID_P: number
SOURCE_CONTINUE: boolean

Use this macro as the return value of a #GSourceFunc to leave the #GSource in the main loop.

SOURCE_REMOVE: boolean

Use this macro as the return value of a #GSourceFunc to remove the #GSource from the main loop.

SQRT2: number

The square root of two.

STR_DELIMITERS: string

The standard delimiters, used in g_strdelimit().

SYSDEF_AF_INET: number
SYSDEF_AF_INET6: number
SYSDEF_AF_UNIX: number
SYSDEF_MSG_DONTROUTE: number
SYSDEF_MSG_OOB: number
SYSDEF_MSG_PEEK: number
TEST_OPTION_ISOLATE_DIRS: string

Creates a unique temporary directory for each unit test and uses g_set_user_dirs() to set XDG directories to point into subdirectories of it for the duration of the unit test. The directory tree is cleaned up after the test finishes successfully. Note that this doesn’t take effect until g_test_run() is called, so calls to (for example) g_get_user_home_dir() will return the system-wide value when made in a test program’s main() function.

The following functions will return subdirectories of the temporary directory when this option is used. The specific subdirectory paths in use are not guaranteed to be stable API — always use a getter function to retrieve them.

  • g_get_home_dir()
  • g_get_user_cache_dir()
  • g_get_system_config_dirs()
  • g_get_user_config_dir()
  • g_get_system_data_dirs()
  • g_get_user_data_dir()
  • g_get_user_state_dir()
  • g_get_user_runtime_dir()

The subdirectories may not be created by the test harness; as with normal calls to functions like g_get_user_cache_dir(), the caller must be prepared to create the directory if it doesn’t exist.

TIME_SPAN_DAY: number

Evaluates to a time span of one day.

TIME_SPAN_HOUR: number

Evaluates to a time span of one hour.

TIME_SPAN_MILLISECOND: number

Evaluates to a time span of one millisecond.

TIME_SPAN_MINUTE: number

Evaluates to a time span of one minute.

TIME_SPAN_SECOND: number

Evaluates to a time span of one second.

UNICHAR_MAX_DECOMPOSITION_LENGTH: number

The maximum length (in codepoints) of a compatibility or canonical decomposition of a single Unicode character.

This is as defined by Unicode 6.1.

URI_RESERVED_CHARS_GENERIC_DELIMITERS: string

Generic delimiters characters as defined in RFC 3986. Includes `:/?#[]```.

URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS: string

Subcomponent delimiter characters as defined in RFC 3986. Includes !$&'()*+,;=.

USEC_PER_SEC: number

Number of microseconds in one second (1 million). This macro is provided for code readability.

VA_COPY_AS_ARRAY: number
VERSION_MIN_REQUIRED: number

A macro that should be defined by the user prior to including the glib.h header. The definition should be one of the predefined GLib version macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,...

This macro defines the earliest version of GLib that the package is required to be able to compile against.

If the compiler is configured to warn about the use of deprecated functions, then using functions that were deprecated in version %GLIB_VERSION_MIN_REQUIRED or earlier will cause warnings (but using functions deprecated in later releases will not).

WIN32_MSG_HANDLE: number
macro__has_attribute___noreturn__: number

Functions

  • access(filename: string, mode: number): number
  • A wrapper for the POSIX access() function. This function is used to test a pathname for one or several of read, write or execute permissions, or just existence.

    On Windows, the file protection mechanism is not at all POSIX-like, and the underlying function in the C library only checks the FAT-style READONLY attribute, and does not look at the ACL of a file at all. This function is this in practise almost useless on Windows. Software that needs to handle file permissions on Windows more exactly should use the Win32 API.

    See your C library manual for more details about access().

    Parameters

    • filename: string

      a pathname in the GLib file name encoding (UTF-8 on Windows)

    • mode: number

      as in access()

    Returns number

  • aligned_alloc(n_blocks: number, n_block_bytes: number, alignment: number): object | null
  • This function is similar to g_malloc(), allocating (n_blocks * n_block_bytes) bytes, but care is taken to align the allocated memory to with the given alignment value. Additionally, it will detect possible overflow during multiplication.

    Aligned memory allocations returned by this function can only be freed using g_aligned_free().

    Parameters

    • n_blocks: number

      the number of blocks to allocate

    • n_block_bytes: number

      the size of each block in bytes

    • alignment: number

      the alignment to be enforced, which must be a positive power of 2 and a multiple of sizeof(void*)

    Returns object | null

  • aligned_alloc0(n_blocks: number, n_block_bytes: number, alignment: number): object | null
  • This function is similar to g_aligned_alloc(), but it will also clear the allocated memory before returning it.

    Parameters

    • n_blocks: number

      the number of blocks to allocate

    • n_block_bytes: number

      the size of each block in bytes

    • alignment: number

      the alignment to be enforced, which must be a positive power of 2 and a multiple of sizeof(void*)

    Returns object | null

  • aligned_free(mem: object): void
  • Frees the memory allocated by g_aligned_alloc().

    Parameters

    • mem: object

      the memory to deallocate

    Returns void

  • ascii_digit_value(c: number): number
  • Determines the numeric value of a character as a decimal digit. Differs from g_unichar_digit_value() because it takes a char, so there's no worry about sign extension if characters are signed.

    Parameters

    • c: number

      an ASCII character

    Returns number

  • ascii_dtostr(buffer: string, buf_len: number, d: number): string
  • Converts a #gdouble to a string, using the '.' as decimal point.

    This function generates enough precision that converting the string back using g_ascii_strtod() gives the same machine-number (on machines with IEEE compatible 64bit doubles). It is guaranteed that the size of the resulting string will never be larger than %G_ASCII_DTOSTR_BUF_SIZE bytes, including the terminating nul character, which is always added.

    Parameters

    • buffer: string

      A buffer to place the resulting string in

    • buf_len: number

      The length of the buffer.

    • d: number

      The #gdouble to convert

    Returns string

  • ascii_formatd(buffer: string, buf_len: number, format: string, d: number): string
  • Converts a #gdouble to a string, using the '.' as decimal point. To format the number you pass in a printf()-style format string. Allowed conversion specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.

    The format must just be a single format specifier starting with %, expecting a #gdouble argument.

    The returned buffer is guaranteed to be nul-terminated.

    If you just want to want to serialize the value into a string, use g_ascii_dtostr().

    Parameters

    • buffer: string

      A buffer to place the resulting string in

    • buf_len: number

      The length of the buffer.

    • format: string

      The printf()-style format to use for the code to use for converting

    • d: number

      The #gdouble to convert

    Returns string

  • ascii_strcasecmp(s1: string, s2: string): number
  • Compare two strings, ignoring the case of ASCII characters.

    Unlike the BSD strcasecmp() function, this only recognizes standard ASCII letters and ignores the locale, treating all non-ASCII bytes as if they are not letters.

    This function should be used only on strings that are known to be in encodings where the bytes corresponding to ASCII letters always represent themselves. This includes UTF-8 and the ISO-8859-* charsets, but not for instance double-byte encodings like the Windows Codepage 932, where the trailing bytes of double-byte characters include all ASCII letters. If you compare two CP932 strings using this function, you will get false matches.

    Both s1 and s2 must be non-%NULL.

    Parameters

    • s1: string

      string to compare with s2

    • s2: string

      string to compare with s1

    Returns number

  • ascii_strdown(str: string, len: number): string
  • Converts all upper case ASCII letters to lower case ASCII letters.

    Parameters

    • str: string

      a string

    • len: number

      length of str in bytes, or -1 if str is nul-terminated

    Returns string

  • ascii_string_to_signed(str: string, base: number, min: number, max: number): [boolean, number]
  • A convenience function for converting a string to a signed number.

    This function assumes that str contains only a number of the given base that is within inclusive bounds limited by min and max. If this is true, then the converted number is stored in out_num. An empty string is not a valid input. A string with leading or trailing whitespace is also an invalid input.

    base can be between 2 and 36 inclusive. Hexadecimal numbers must not be prefixed with "0x" or "0X". Such a problem does not exist for octal numbers, since they were usually prefixed with a zero which does not change the value of the parsed number.

    Parsing failures result in an error with the %G_NUMBER_PARSER_ERROR domain. If the input is invalid, the error code will be %G_NUMBER_PARSER_ERROR_INVALID. If the parsed number is out of bounds - %G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS.

    See g_ascii_strtoll() if you have more complex needs such as parsing a string which starts with a number, but then has other characters.

    Parameters

    • str: string

      a string

    • base: number

      base of a parsed number

    • min: number

      a lower bound (inclusive)

    • max: number

      an upper bound (inclusive)

    Returns [boolean, number]

  • ascii_string_to_unsigned(str: string, base: number, min: number, max: number): [boolean, number]
  • A convenience function for converting a string to an unsigned number.

    This function assumes that str contains only a number of the given base that is within inclusive bounds limited by min and max. If this is true, then the converted number is stored in out_num. An empty string is not a valid input. A string with leading or trailing whitespace is also an invalid input. A string with a leading sign (- or +) is not a valid input for the unsigned parser.

    base can be between 2 and 36 inclusive. Hexadecimal numbers must not be prefixed with "0x" or "0X". Such a problem does not exist for octal numbers, since they were usually prefixed with a zero which does not change the value of the parsed number.

    Parsing failures result in an error with the %G_NUMBER_PARSER_ERROR domain. If the input is invalid, the error code will be %G_NUMBER_PARSER_ERROR_INVALID. If the parsed number is out of bounds - %G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS.

    See g_ascii_strtoull() if you have more complex needs such as parsing a string which starts with a number, but then has other characters.

    Parameters

    • str: string

      a string

    • base: number

      base of a parsed number

    • min: number

      a lower bound (inclusive)

    • max: number

      an upper bound (inclusive)

    Returns [boolean, number]

  • ascii_strncasecmp(s1: string, s2: string, n: number): number
  • Compare s1 and s2, ignoring the case of ASCII characters and any characters after the first n in each string. If either string is less than n bytes long, comparison will stop at the first nul byte encountered.

    Unlike the BSD strcasecmp() function, this only recognizes standard ASCII letters and ignores the locale, treating all non-ASCII characters as if they are not letters.

    The same warning as in g_ascii_strcasecmp() applies: Use this function only on strings known to be in encodings where bytes corresponding to ASCII letters always represent themselves.

    Parameters

    • s1: string

      string to compare with s2

    • s2: string

      string to compare with s1

    • n: number

      number of characters to compare

    Returns number

  • ascii_strtod(nptr: string): [number, string]
  • Converts a string to a #gdouble value.

    This function behaves like the standard strtod() function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe. A limitation of the implementation is that this function will still accept localized versions of infinities and NANs.

    This function is typically used when reading configuration files or other non-user input that should be locale independent. To handle input from the user you should normally use the locale-sensitive system strtod() function.

    To convert from a #gdouble to a string in a locale-insensitive way, use g_ascii_dtostr().

    If the correct value would cause overflow, plus or minus %HUGE_VAL is returned (according to the sign of the value), and %ERANGE is stored in %errno. If the correct value would cause underflow, zero is returned and %ERANGE is stored in %errno.

    This function resets %errno before calling strtod() so that you can reliably detect overflow and underflow.

    Parameters

    • nptr: string

      the string to convert to a numeric value.

    Returns [number, string]

  • ascii_strtoll(nptr: string, base: number): [number, string]
  • Converts a string to a #gint64 value. This function behaves like the standard strtoll() function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe.

    This function is typically used when reading configuration files or other non-user input that should be locale independent. To handle input from the user you should normally use the locale-sensitive system strtoll() function.

    If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64 is returned, and ERANGE is stored in errno. If the base is outside the valid range, zero is returned, and EINVAL is stored in errno. If the string conversion fails, zero is returned, and endptr returns nptr (if endptr is non-%NULL).

    Parameters

    • nptr: string

      the string to convert to a numeric value.

    • base: number

      to be used for the conversion, 2..36 or 0

    Returns [number, string]

  • ascii_strtoull(nptr: string, base: number): [number, string]
  • Converts a string to a #guint64 value. This function behaves like the standard strtoull() function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe.

    Note that input with a leading minus sign (-) is accepted, and will return the negation of the parsed number, unless that would overflow a #guint64. Critically, this means you cannot assume that a short fixed length input will never result in a low return value, as the input could have a leading -.

    This function is typically used when reading configuration files or other non-user input that should be locale independent. To handle input from the user you should normally use the locale-sensitive system strtoull() function.

    If the correct value would cause overflow, %G_MAXUINT64 is returned, and ERANGE is stored in errno. If the base is outside the valid range, zero is returned, and EINVAL is stored in errno. If the string conversion fails, zero is returned, and endptr returns nptr (if endptr is non-%NULL).

    Parameters

    • nptr: string

      the string to convert to a numeric value.

    • base: number

      to be used for the conversion, 2..36 or 0

    Returns [number, string]

  • ascii_strup(str: string, len: number): string
  • Converts all lower case ASCII letters to upper case ASCII letters.

    Parameters

    • str: string

      a string

    • len: number

      length of str in bytes, or -1 if str is nul-terminated

    Returns string

  • ascii_tolower(c: number): number
  • Convert a character to ASCII lower case.

    Unlike the standard C library tolower() function, this only recognizes standard ASCII letters and ignores the locale, returning all non-ASCII characters unchanged, even if they are lower case letters in a particular character set. Also unlike the standard library function, this takes and returns a char, not an int, so don't call it on %EOF but no need to worry about casting to #guchar before passing a possibly non-ASCII character in.

    Parameters

    • c: number

      any character

    Returns number

  • ascii_toupper(c: number): number
  • Convert a character to ASCII upper case.

    Unlike the standard C library toupper() function, this only recognizes standard ASCII letters and ignores the locale, returning all non-ASCII characters unchanged, even if they are upper case letters in a particular character set. Also unlike the standard library function, this takes and returns a char, not an int, so don't call it on %EOF but no need to worry about casting to #guchar before passing a possibly non-ASCII character in.

    Parameters

    • c: number

      any character

    Returns number

  • ascii_xdigit_value(c: number): number
  • Determines the numeric value of a character as a hexadecimal digit. Differs from g_unichar_xdigit_value() because it takes a char, so there's no worry about sign extension if characters are signed.

    Parameters

    • c: number

      an ASCII character.

    Returns number

  • assert_warning(log_domain: string, file: string, line: number, pretty_function: string, expression: string): void
  • Parameters

    • log_domain: string
    • file: string
    • line: number
    • pretty_function: string
    • expression: string

    Returns void

  • assertion_message(domain: string, file: string, line: number, func: string, message: string): void
  • assertion_message_cmpstr(domain: string, file: string, line: number, func: string, expr: string, arg1: string, cmp: string, arg2: string): void
  • Parameters

    • domain: string
    • file: string
    • line: number
    • func: string
    • expr: string
    • arg1: string
    • cmp: string
    • arg2: string

    Returns void

  • assertion_message_cmpstrv(domain: string, file: string, line: number, func: string, expr: string, arg1: string, arg2: string, first_wrong_idx: number): void
  • Parameters

    • domain: string
    • file: string
    • line: number
    • func: string
    • expr: string
    • arg1: string
    • arg2: string
    • first_wrong_idx: number

    Returns void

  • assertion_message_error(domain: string, file: string, line: number, func: string, expr: string, error: GLib.Error, error_domain: number, error_code: number): void
  • Specifies a function to be called at normal program termination.

    Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor macro that maps to a call to the atexit() function in the C library. This means that in case the code that calls g_atexit(), i.e. atexit(), is in a DLL, the function will be called when the DLL is detached from the program. This typically makes more sense than that the function is called when the GLib DLL is detached, which happened earlier when g_atexit() was a function in the GLib DLL.

    The behaviour of atexit() in the context of dynamically loaded modules is not formally specified and varies wildly.

    On POSIX systems, calling g_atexit() (or atexit()) in a dynamically loaded module which is unloaded before the program terminates might well cause a crash at program exit.

    Some POSIX systems implement atexit() like Windows, and have each dynamically loaded module maintain an own atexit chain that is called when the module is unloaded.

    On other POSIX systems, before a dynamically loaded module is unloaded, the registered atexit functions (if any) residing in that module are called, regardless where the code that registered them resided. This is presumably the most robust approach.

    As can be seen from the above, for portability it's best to avoid calling g_atexit() (or atexit()) except in the main executable of a program.

    Parameters

    • func: GLib.VoidFunc

      the function to call on normal program termination.

    Returns void

  • atomic_int_add(atomic: number, val: number): number
  • Atomically adds val to the value of atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic += val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    Before version 2.30, this function did not return a value (but g_atomic_int_exchange_and_add() did, and had the same meaning).

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    • val: number

      the value to add

    Returns number

  • atomic_int_and(atomic: number, val: number): number
  • Performs an atomic bitwise 'and' of the value of atomic and val, storing the result back in atomic.

    This call acts as a full compiler and hardware memory barrier.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic &= val; return tmp; }.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    • val: number

      the value to 'and'

    Returns number

  • atomic_int_compare_and_exchange(atomic: number, oldval: number, newval: number): boolean
  • Compares atomic to oldval and, if equal, sets it to newval. If atomic was not equal to oldval then no change occurs.

    This compare and exchange is done atomically.

    Think of this operation as an atomic version of { if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    • oldval: number

      the value to compare with

    • newval: number

      the value to conditionally replace with

    Returns boolean

  • atomic_int_dec_and_test(atomic: number): boolean
  • Decrements the value of atomic by 1.

    Think of this operation as an atomic version of { *atomic -= 1; return (*atomic == 0); }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    Returns boolean

  • atomic_int_exchange_and_add(atomic: number, val: number): number
  • This function existed before g_atomic_int_add() returned the prior value of the integer (which it now does). It is retained only for compatibility reasons. Don't use this function in new code.

    Parameters

    • atomic: number

      a pointer to a #gint

    • val: number

      the value to add

    Returns number

  • atomic_int_get(atomic: number): number
  • Gets the current value of atomic.

    This call acts as a full compiler and hardware memory barrier (before the get).

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    Returns number

  • atomic_int_inc(atomic: number): void
  • Increments the value of atomic by 1.

    Think of this operation as an atomic version of { *atomic += 1; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    Returns void

  • atomic_int_or(atomic: number, val: number): number
  • Performs an atomic bitwise 'or' of the value of atomic and val, storing the result back in atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic |= val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    • val: number

      the value to 'or'

    Returns number

  • atomic_int_set(atomic: number, newval: number): void
  • Sets the value of atomic to newval.

    This call acts as a full compiler and hardware memory barrier (after the set).

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    • newval: number

      a new value to store

    Returns void

  • atomic_int_xor(atomic: number, val: number): number
  • Performs an atomic bitwise 'xor' of the value of atomic and val, storing the result back in atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic ^= val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: number

      a pointer to a #gint or #guint

    • val: number

      the value to 'xor'

    Returns number

  • atomic_pointer_add(atomic: object, val: number): number
  • Atomically adds val to the value of atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic += val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    • val: number

      the value to add

    Returns number

  • atomic_pointer_and(atomic: object, val: number): number
  • Performs an atomic bitwise 'and' of the value of atomic and val, storing the result back in atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic &= val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    • val: number

      the value to 'and'

    Returns number

  • atomic_pointer_compare_and_exchange(atomic: object, oldval: object, newval: object): boolean
  • Compares atomic to oldval and, if equal, sets it to newval. If atomic was not equal to oldval then no change occurs.

    This compare and exchange is done atomically.

    Think of this operation as an atomic version of { if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    • oldval: object

      the value to compare with

    • newval: object

      the value to conditionally replace with

    Returns boolean

  • atomic_pointer_get(atomic: object): object | null
  • Gets the current value of atomic.

    This call acts as a full compiler and hardware memory barrier (before the get).

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    Returns object | null

  • atomic_pointer_or(atomic: object, val: number): number
  • Performs an atomic bitwise 'or' of the value of atomic and val, storing the result back in atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic |= val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    • val: number

      the value to 'or'

    Returns number

  • atomic_pointer_set(atomic: object, newval: object): void
  • Sets the value of atomic to newval.

    This call acts as a full compiler and hardware memory barrier (after the set).

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    • newval: object

      a new value to store

    Returns void

  • atomic_pointer_xor(atomic: object, val: number): number
  • Performs an atomic bitwise 'xor' of the value of atomic and val, storing the result back in atomic.

    Think of this operation as an atomic version of { tmp = *atomic; *atomic ^= val; return tmp; }.

    This call acts as a full compiler and hardware memory barrier.

    While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile.

    Parameters

    • atomic: object

      a pointer to a #gpointer-sized value

    • val: number

      the value to 'xor'

    Returns number

  • atomic_rc_box_acquire(mem_block: object): object
  • Atomically acquires a reference on the data pointed by mem_block.

    Parameters

    • mem_block: object

      a pointer to reference counted data

    Returns object

  • atomic_rc_box_alloc(block_size: number): object
  • Allocates block_size bytes of memory, and adds atomic reference counting semantics to it.

    The data will be freed when its reference count drops to zero.

    The allocated data is guaranteed to be suitably aligned for any built-in type.

    Parameters

    • block_size: number

      the size of the allocation, must be greater than 0

    Returns object

  • atomic_rc_box_alloc0(block_size: number): object
  • Allocates block_size bytes of memory, and adds atomic reference counting semantics to it.

    The contents of the returned data is set to zero.

    The data will be freed when its reference count drops to zero.

    The allocated data is guaranteed to be suitably aligned for any built-in type.

    Parameters

    • block_size: number

      the size of the allocation, must be greater than 0

    Returns object

  • atomic_rc_box_dup(block_size: number, mem_block: object): object
  • Allocates a new block of data with atomic reference counting semantics, and copies block_size bytes of mem_block into it.

    Parameters

    • block_size: number

      the number of bytes to copy, must be greater than 0

    • mem_block: object

      the memory to copy

    Returns object

  • atomic_rc_box_get_size(mem_block: object): number
  • Retrieves the size of the reference counted data pointed by mem_block.

    Parameters

    • mem_block: object

      a pointer to reference counted data

    Returns number

  • atomic_rc_box_release(mem_block: object): void
  • Atomically releases a reference on the data pointed by mem_block.

    If the reference was the last one, it will free the resources allocated for mem_block.

    Parameters

    • mem_block: object

      a pointer to reference counted data

    Returns void

  • Atomically releases a reference on the data pointed by mem_block.

    If the reference was the last one, it will call clear_func to clear the contents of mem_block, and then will free the resources allocated for mem_block.

    Parameters

    • mem_block: object

      a pointer to reference counted data

    • clear_func: GLib.DestroyNotify

      a function to call when clearing the data

    Returns void

  • atomic_ref_count_compare(arc: number, val: number): boolean
  • Atomically compares the current value of arc with val.

    Parameters

    • arc: number

      the address of an atomic reference count variable

    • val: number

      the value to compare

    Returns boolean

  • atomic_ref_count_dec(arc: number): boolean
  • Atomically decreases the reference count.

    If %TRUE is returned, the reference count reached 0. After this point, arc is an undefined state and must be reinitialized with g_atomic_ref_count_init() to be used again.

    Parameters

    • arc: number

      the address of an atomic reference count variable

    Returns boolean

  • atomic_ref_count_inc(arc: number): void
  • Atomically increases the reference count.

    Parameters

    • arc: number

      the address of an atomic reference count variable

    Returns void

  • atomic_ref_count_init(arc: number): void
  • Initializes a reference count variable to 1.

    Parameters

    • arc: number

      the address of an atomic reference count variable

    Returns void

  • base64_decode(text: string): Uint8Array
  • Decode a sequence of Base-64 encoded text into binary data. Note that the returned binary data is not necessarily zero-terminated, so it should not be used as a character string.

    Parameters

    • text: string

      zero-terminated string with base64 text to decode

    Returns Uint8Array

  • base64_decode_inplace(text: Uint8Array): [number, Uint8Array]
  • Decode a sequence of Base-64 encoded text into binary data by overwriting the input data.

    Parameters

    • text: Uint8Array

      zero-terminated string with base64 text to decode

    Returns [number, Uint8Array]

  • base64_encode(data: Uint8Array): string
  • Encode a sequence of binary data into its Base-64 stringified representation.

    Parameters

    • data: Uint8Array

      the binary data to encode

    Returns string

  • base64_encode_close(break_lines: boolean, state: number, save: number): [number, Uint8Array, number, number]
  • Flush the status from a sequence of calls to g_base64_encode_step().

    The output buffer must be large enough to fit all the data that will be written to it. It will need up to 4 bytes, or up to 5 bytes if line-breaking is enabled.

    The out array will not be automatically nul-terminated.

    Parameters

    • break_lines: boolean

      whether to break long lines

    • state: number

      Saved state from g_base64_encode_step()

    • save: number

      Saved state from g_base64_encode_step()

    Returns [number, Uint8Array, number, number]

  • base64_encode_step(in_: Uint8Array, break_lines: boolean, state: number, save: number): [number, Uint8Array, number, number]
  • Incrementally encode a sequence of binary data into its Base-64 stringified representation. By calling this function multiple times you can convert data in chunks to avoid having to have the full encoded data in memory.

    When all of the data has been converted you must call g_base64_encode_close() to flush the saved state.

    The output buffer must be large enough to fit all the data that will be written to it. Due to the way base64 encodes you will need at least: (len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of non-zero state). If you enable line-breaking you will need at least: ((len / 3 + 1) * 4 + 4) / 76 + 1 bytes of extra space.

    break_lines is typically used when putting base64-encoded data in emails. It breaks the lines at 76 columns instead of putting all of the text on the same line. This avoids problems with long lines in the email system. Note however that it breaks the lines with LF characters, not CR LF sequences, so the result cannot be passed directly to SMTP or certain other protocols.

    Parameters

    • in_: Uint8Array

      the binary data to encode

    • break_lines: boolean

      whether to break long lines

    • state: number

      Saved state between steps, initialize to 0

    • save: number

      Saved state between steps, initialize to 0

    Returns [number, Uint8Array, number, number]

  • basename(file_name: string): string
  • Gets the name of the file without any leading directory components. It returns a pointer into the given file name string.

    Parameters

    • file_name: string

      the name of the file

    Returns string

  • bit_lock(address: number, lock_bit: number): void
  • Sets the indicated lock_bit in address. If the bit is already set, this call will block until g_bit_unlock() unsets the corresponding bit.

    Attempting to lock on two different bits within the same integer is not supported and will very probably cause deadlocks.

    The value of the bit that is set is (1u << bit). If bit is not between 0 and 31 then the result is undefined.

    This function accesses address atomically. All other accesses to address must be atomic in order for this function to work reliably. While address has a volatile qualifier, this is a historical artifact and the argument passed to it should not be volatile.

    Parameters

    • address: number

      a pointer to an integer

    • lock_bit: number

      a bit value between 0 and 31

    Returns void

  • bit_nth_lsf(mask: number, nth_bit: number): number
  • Find the position of the first bit set in mask, searching from (but not including) nth_bit upwards. Bits are numbered from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the 0th bit, set nth_bit to -1.

    Parameters

    • mask: number

      a #gulong containing flags

    • nth_bit: number

      the index of the bit to start the search from

    Returns number

  • bit_nth_msf(mask: number, nth_bit: number): number
  • Find the position of the first bit set in mask, searching from (but not including) nth_bit downwards. Bits are numbered from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the last bit, set nth_bit to -1 or GLIB_SIZEOF_LONG * 8.

    Parameters

    • mask: number

      a #gulong containing flags

    • nth_bit: number

      the index of the bit to start the search from

    Returns number

  • bit_storage(number: number): number
  • Gets the number of bits used to hold number, e.g. if number is 4, 3 bits are needed.

    Parameters

    • number: number

      a #guint

    Returns number

  • bit_trylock(address: number, lock_bit: number): boolean
  • Sets the indicated lock_bit in address, returning %TRUE if successful. If the bit is already set, returns %FALSE immediately.

    Attempting to lock on two different bits within the same integer is not supported.

    The value of the bit that is set is (1u << bit). If bit is not between 0 and 31 then the result is undefined.

    This function accesses address atomically. All other accesses to address must be atomic in order for this function to work reliably. While address has a volatile qualifier, this is a historical artifact and the argument passed to it should not be volatile.

    Parameters

    • address: number

      a pointer to an integer

    • lock_bit: number

      a bit value between 0 and 31

    Returns boolean

  • bit_unlock(address: number, lock_bit: number): void
  • Clears the indicated lock_bit in address. If another thread is currently blocked in g_bit_lock() on this same bit then it will be woken up.

    This function accesses address atomically. All other accesses to address must be atomic in order for this function to work reliably. While address has a volatile qualifier, this is a historical artifact and the argument passed to it should not be volatile.

    Parameters

    • address: number

      a pointer to an integer

    • lock_bit: number

      a bit value between 0 and 31

    Returns void

  • bookmark_file_error_quark(): Quark
  • build_filenamev(args: string[]): string
  • Behaves exactly like g_build_filename(), but takes the path elements as a string array, instead of varargs. This function is mainly meant for language bindings.

    Parameters

    • args: string[]

      %NULL-terminated array of strings containing the path elements.

    Returns string

  • build_pathv(separator: string, args: string[]): string
  • Behaves exactly like g_build_path(), but takes the path elements as a string array, instead of varargs. This function is mainly meant for language bindings.

    Parameters

    • separator: string

      a string used to separator the elements of the path.

    • args: string[]

      %NULL-terminated array of strings containing the path elements.

    Returns string

  • byte_array_free(array: Uint8Array, free_segment: boolean): number
  • Frees the memory allocated by the #GByteArray. If free_segment is %TRUE it frees the actual byte data. If the reference count of array is greater than one, the #GByteArray wrapper is preserved but the size of array will be set to zero.

    Parameters

    • array: Uint8Array

      a #GByteArray

    • free_segment: boolean

      if %TRUE the actual byte data is freed as well

    Returns number

  • byte_array_free_to_bytes(array: Uint8Array): Bytes
  • Transfers the data from the #GByteArray into a new immutable #GBytes.

    The #GByteArray is freed unless the reference count of array is greater than one, the #GByteArray wrapper is preserved but the size of array will be set to zero.

    This is identical to using g_bytes_new_take() and g_byte_array_free() together.

    Parameters

    • array: Uint8Array

      a #GByteArray

    Returns Bytes

  • byte_array_new(): Uint8Array
  • byte_array_new_take(data: Uint8Array): Uint8Array
  • Create byte array containing the data. The data will be owned by the array and will be freed with g_free(), i.e. it could be allocated using g_strdup().

    Do not use it if len is greater than %G_MAXUINT. #GByteArray stores the length of its data in #guint, which may be shorter than #gsize.

    Parameters

    • data: Uint8Array

      byte data for the array

    Returns Uint8Array

  • byte_array_steal(array: Uint8Array): [number, number]
  • Frees the data in the array and resets the size to zero, while the underlying array is preserved for use elsewhere and returned to the caller.

    Parameters

    • array: Uint8Array

      a #GByteArray.

    Returns [number, number]

  • byte_array_unref(array: Uint8Array): void
  • Atomically decrements the reference count of array by one. If the reference count drops to 0, all memory allocated by the array is released. This function is thread-safe and may be called from any thread.

    Parameters

    • array: Uint8Array

      A #GByteArray

    Returns void

  • canonicalize_filename(filename: string, relative_to: string): string
  • Gets the canonical file name from filename. All triple slashes are turned into single slashes, and all .. and .s resolved against relative_to.

    Symlinks are not followed, and the returned path is guaranteed to be absolute.

    If filename is an absolute path, relative_to is ignored. Otherwise, relative_to will be prepended to filename to make it absolute. relative_to must be an absolute path, or %NULL. If relative_to is %NULL, it'll fallback to g_get_current_dir().

    This function never fails, and will canonicalize file paths even if they don't exist.

    No file system I/O is done.

    Parameters

    • filename: string

      the name of the file

    • relative_to: string

      the relative directory, or %NULL to use the current working directory

    Returns string

  • chdir(path: string): number
  • A wrapper for the POSIX chdir() function. The function changes the current directory of the process to path.

    See your C library manual for more details about chdir().

    Parameters

    • path: string

      a pathname in the GLib file name encoding (UTF-8 on Windows)

    Returns number

  • check_version(required_major: number, required_minor: number, required_micro: number): string | null
  • Checks that the GLib library in use is compatible with the given version.

    Generally you would pass in the constants %GLIB_MAJOR_VERSION, %GLIB_MINOR_VERSION, %GLIB_MICRO_VERSION as the three arguments to this function; that produces a check that the library in use is compatible with the version of GLib the application or module was compiled against.

    Compatibility is defined by two things: first the version of the running library is newer than the version required_major`.required_minor.`required_micro. Second the running library must be binary compatible with the version required_major`.`required_minor`.`required_micro (same major version.)

    Parameters

    • required_major: number

      the required major version

    • required_minor: number

      the required minor version

    • required_micro: number

      the required micro version

    Returns string | null

  • checksum_type_get_length(checksum_type: ChecksumType): number
  • child_watch_add(priority: number, pid: number, function_: ChildWatchFunc): number
  • Sets a function to be called when the child indicated by pid exits, at the priority priority.

    If you obtain pid from g_spawn_async() or g_spawn_async_with_pipes() you will need to pass %G_SPAWN_DO_NOT_REAP_CHILD as flag to the spawn function for the child watching to work.

    In many programs, you will want to call g_spawn_check_wait_status() in the callback to determine whether or not the child exited successfully.

    Also, note that on platforms where #GPid must be explicitly closed (see g_spawn_close_pid()) pid must not be closed while the source is still active. Typically, you should invoke g_spawn_close_pid() in the callback function for the source.

    GLib supports only a single callback per process id. On POSIX platforms, the same restrictions mentioned for g_child_watch_source_new() apply to this function.

    This internally creates a main loop source using g_child_watch_source_new() and attaches it to the main loop context using g_source_attach(). You can do these steps manually if you need greater control.

    Parameters

    • priority: number

      the priority of the idle source. Typically this will be in the range between %G_PRIORITY_DEFAULT_IDLE and %G_PRIORITY_HIGH_IDLE.

    • pid: number

      process to watch. On POSIX the positive pid of a child process. On Windows a handle for a process (which doesn't have to be a child).

    • function_: ChildWatchFunc

      function to call

    Returns number

  • Creates a new child_watch source.

    The source will not initially be associated with any #GMainContext and must be added to one with g_source_attach() before it will be executed.

    Note that child watch sources can only be used in conjunction with g_spawn... when the %G_SPAWN_DO_NOT_REAP_CHILD flag is used.

    Note that on platforms where #GPid must be explicitly closed (see g_spawn_close_pid()) pid must not be closed while the source is still active. Typically, you will want to call g_spawn_close_pid() in the callback function for the source.

    On POSIX platforms, the following restrictions apply to this API due to limitations in POSIX process interfaces:

    • pid must be a child of this process
    • pid must be positive
    • the application must not call waitpid with a non-positive first argument, for instance in another thread
    • the application must not wait for pid to exit by any other mechanism, including waitpid(pid, ...) or a second child-watch source for the same pid
    • the application must not ignore SIGCHLD

    If any of those conditions are not met, this and related APIs will not work correctly. This can often be diagnosed via a GLib warning stating that ECHILD was received by waitpid.

    Calling waitpid for specific processes other than pid remains a valid thing to do.

    Parameters

    • pid: number

      process to watch. On POSIX the positive pid of a child process. On Windows a handle for a process (which doesn't have to be a child).

    Returns GLib.Source

  • clear_error(): void
  • If err or *err is %NULL, does nothing. Otherwise, calls g_error_free() on *err and sets *err to %NULL.

    Returns void

  • close(fd: number): boolean
  • This wraps the close() call; in case of error, %errno will be preserved, but the error will also be stored as a #GError in error.

    Besides using #GError, there is another major reason to prefer this function over the call provided by the system; on Unix, it will attempt to correctly handle %EINTR, which has platform-specific semantics.

    Parameters

    • fd: number

      A file descriptor

    Returns boolean

  • Computes the checksum for a binary data. This is a convenience wrapper for g_checksum_new(), g_checksum_get_string() and g_checksum_free().

    The hexadecimal string returned will be in lower case.

    Parameters

    • checksum_type: ChecksumType

      a #GChecksumType

    • data: Bytes

      binary blob to compute the digest of

    Returns string | null

  • compute_checksum_for_data(checksum_type: ChecksumType, data: Uint8Array): string | null
  • Computes the checksum for a binary data of length. This is a convenience wrapper for g_checksum_new(), g_checksum_get_string() and g_checksum_free().

    The hexadecimal string returned will be in lower case.

    Parameters

    • checksum_type: ChecksumType

      a #GChecksumType

    • data: Uint8Array

      binary blob to compute the digest of

    Returns string | null

  • compute_checksum_for_string(checksum_type: ChecksumType, str: string, length: number): string | null
  • Computes the checksum of a string.

    The hexadecimal string returned will be in lower case.

    Parameters

    • checksum_type: ChecksumType

      a #GChecksumType

    • str: string

      the string to compute the checksum of

    • length: number

      the length of the string, or -1 if the string is null-terminated.

    Returns string | null

  • Computes the HMAC for a binary data. This is a convenience wrapper for g_hmac_new(), g_hmac_get_string() and g_hmac_unref().

    The hexadecimal string returned will be in lower case.

    Parameters

    • digest_type: ChecksumType

      a #GChecksumType to use for the HMAC

    • key: Bytes

      the key to use in the HMAC

    • data: Bytes

      binary blob to compute the HMAC of

    Returns string

  • compute_hmac_for_data(digest_type: ChecksumType, key: Uint8Array, data: Uint8Array): string
  • Computes the HMAC for a binary data of length. This is a convenience wrapper for g_hmac_new(), g_hmac_get_string() and g_hmac_unref().

    The hexadecimal string returned will be in lower case.

    Parameters

    • digest_type: ChecksumType

      a #GChecksumType to use for the HMAC

    • key: Uint8Array

      the key to use in the HMAC

    • data: Uint8Array

      binary blob to compute the HMAC of

    Returns string

  • compute_hmac_for_string(digest_type: ChecksumType, key: Uint8Array, str: string, length: number): string
  • Computes the HMAC for a string.

    The hexadecimal string returned will be in lower case.

    Parameters

    • digest_type: ChecksumType

      a #GChecksumType to use for the HMAC

    • key: Uint8Array

      the key to use in the HMAC

    • str: string

      the string to compute the HMAC for

    • length: number

      the length of the string, or -1 if the string is nul-terminated

    Returns string

  • convert(str: Uint8Array, to_codeset: string, from_codeset: string): [Uint8Array, number]
  • Converts a string from one character set to another.

    Note that you should use g_iconv() for streaming conversions. Despite the fact that bytes_read can return information about partial characters, the g_convert_... functions are not generally suitable for streaming. If the underlying converter maintains internal state, then this won't be preserved across successive calls to g_convert(), g_convert_with_iconv() or g_convert_with_fallback(). (An example of this is the GNU C converter for CP1255 which does not emit a base character until it knows that the next character is not a mark that could combine with the base character.)

    Using extensions such as "//TRANSLIT" may not work (or may not work well) on many platforms. Consider using g_str_to_ascii() instead.

    Parameters

    • str: Uint8Array

      the string to convert.

    • to_codeset: string

      name of character set into which to convert str

    • from_codeset: string

      character set of str.

    Returns [Uint8Array, number]

  • convert_error_quark(): Quark
  • convert_with_fallback(str: Uint8Array, to_codeset: string, from_codeset: string, fallback: string): [Uint8Array, number]
  • Converts a string from one character set to another, possibly including fallback sequences for characters not representable in the output. Note that it is not guaranteed that the specification for the fallback sequences in fallback will be honored. Some systems may do an approximate conversion from from_codeset to to_codeset in their iconv() functions, in which case GLib will simply return that approximate conversion.

    Note that you should use g_iconv() for streaming conversions. Despite the fact that bytes_read can return information about partial characters, the g_convert_... functions are not generally suitable for streaming. If the underlying converter maintains internal state, then this won't be preserved across successive calls to g_convert(), g_convert_with_iconv() or g_convert_with_fallback(). (An example of this is the GNU C converter for CP1255 which does not emit a base character until it knows that the next character is not a mark that could combine with the base character.)

    Parameters

    • str: Uint8Array

      the string to convert.

    • to_codeset: string

      name of character set into which to convert str

    • from_codeset: string

      character set of str.

    • fallback: string

      UTF-8 string to use in place of characters not present in the target encoding. (The string must be representable in the target encoding). If %NULL, characters not in the target encoding will be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.

    Returns [Uint8Array, number]

  • Calls the given function for each data element of the datalist. The function is called with each data element's #GQuark id and data, together with the given user_data parameter. Note that this function is NOT thread-safe. So unless datalist can be protected from any modifications during invocation of this function, it should not be called.

    func can make changes to datalist, but the iteration will not reflect changes made during the g_datalist_foreach() call, other than skipping over elements that are removed.

    Parameters

    Returns void

  • datalist_get_data(datalist: GLib.Data, key: string): object | null
  • Gets a data element, using its string identifier. This is slower than g_datalist_id_get_data() because it compares strings.

    Parameters

    • datalist: GLib.Data

      a datalist.

    • key: string

      the string identifying a data element.

    Returns object | null

  • datalist_get_flags(datalist: GLib.Data): number
  • Gets flags values packed in together with the datalist. See g_datalist_set_flags().

    Parameters

    • datalist: GLib.Data

      pointer to the location that holds a list

    Returns number

  • datalist_id_get_data(datalist: GLib.Data, key_id: number): object | null
  • Retrieves the data element corresponding to key_id.

    Parameters

    • datalist: GLib.Data

      a datalist.

    • key_id: number

      the #GQuark identifying a data element.

    Returns object | null

  • datalist_set_flags(datalist: GLib.Data, flags: number): void
  • Turns on flag values for a data list. This function is used to keep a small number of boolean flags in an object with a data list without using any additional space. It is not generally useful except in circumstances where space is very tight. (It is used in the base #GObject type, for example.)

    Parameters

    • datalist: GLib.Data

      pointer to the location that holds a list

    • flags: number

      the flags to turn on. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3; giving two possible boolean flags). A value for flags that doesn't fit within the mask is an error.

    Returns void

  • datalist_unset_flags(datalist: GLib.Data, flags: number): void
  • Turns off flag values for a data list. See g_datalist_unset_flags()

    Parameters

    • datalist: GLib.Data

      pointer to the location that holds a list

    • flags: number

      the flags to turn off. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3: giving two possible boolean flags). A value for flags that doesn't fit within the mask is an error.

    Returns void

  • dataset_destroy(dataset_location: object): void
  • Destroys the dataset, freeing all memory allocated, and calling any destroy functions set for data elements.

    Parameters

    • dataset_location: object

      the location identifying the dataset.

    Returns void

  • Calls the given function for each data element which is associated with the given location. Note that this function is NOT thread-safe. So unless dataset_location can be protected from any modifications during invocation of this function, it should not be called.

    func can make changes to the dataset, but the iteration will not reflect changes made during the g_dataset_foreach() call, other than skipping over elements that are removed.

    Parameters

    • dataset_location: object

      the location identifying the dataset.

    • func: DataForeachFunc

      the function to call for each data element.

    Returns void

  • dataset_id_get_data(dataset_location: object, key_id: number): object | null
  • Gets the data element corresponding to a #GQuark.

    Parameters

    • dataset_location: object

      the location identifying the dataset.

    • key_id: number

      the #GQuark id to identify the data element.

    Returns object | null

  • date_get_days_in_month(month: DateMonth, year: number): number
  • date_get_monday_weeks_in_year(year: number): number
  • Returns the number of weeks in the year, where weeks are taken to start on Monday. Will be 52 or 53. The date must be valid. (Years always have 52 7-day periods, plus 1 or 2 extra days depending on whether it's a leap year. This function is basically telling you how many Mondays are in the year, i.e. there are 53 Mondays if one of the extra days happens to be a Monday.)

    Parameters

    • year: number

      a year

    Returns number

  • date_get_sunday_weeks_in_year(year: number): number
  • Returns the number of weeks in the year, where weeks are taken to start on Sunday. Will be 52 or 53. The date must be valid. (Years always have 52 7-day periods, plus 1 or 2 extra days depending on whether it's a leap year. This function is basically telling you how many Sundays are in the year, i.e. there are 53 Sundays if one of the extra days happens to be a Sunday.)

    Parameters

    • year: number

      year to count weeks in

    Returns number

  • date_is_leap_year(year: number): boolean
  • Returns %TRUE if the year is a leap year.

    For the purposes of this function, leap year is every year divisible by 4 unless that year is divisible by 100. If it is divisible by 100 it would be a leap year only if that year is also divisible by 400.

    Parameters

    • year: number

      year to check

    Returns boolean

  • date_strftime(s: string, slen: number, format: string, date: GLib.Date): number
  • Generates a printed representation of the date, in a [locale][setlocale]-specific way. Works just like the platform's C library strftime() function, but only accepts date-related formats; time-related formats give undefined results. Date must be valid. Unlike strftime() (which uses the locale encoding), works on a UTF-8 format string and stores a UTF-8 result.

    This function does not provide any conversion specifiers in addition to those implemented by the platform's C library. For example, don't expect that using g_date_strftime() would make the %F provided by the C99 strftime() work on Windows where the C library only complies to C89.

    Parameters

    • s: string

      destination buffer

    • slen: number

      buffer size

    • format: string

      format string

    • date: GLib.Date

      valid #GDate

    Returns number

  • date_valid_day(day: number): boolean
  • Returns %TRUE if the day of the month is valid (a day is valid if it's between 1 and 31 inclusive).

    Parameters

    • day: number

      day to check

    Returns boolean

  • date_valid_dmy(day: number, month: DateMonth, year: number): boolean
  • Returns %TRUE if the day-month-year triplet forms a valid, existing day in the range of days #GDate understands (Year 1 or later, no more than a few thousand years in the future).

    Parameters

    • day: number

      day

    • month: DateMonth

      month

    • year: number

      year

    Returns boolean

  • date_valid_julian(julian_date: number): boolean
  • Returns %TRUE if the Julian day is valid. Anything greater than zero is basically a valid Julian, though there is a 32-bit limit.

    Parameters

    • julian_date: number

      Julian day to check

    Returns boolean

  • Returns %TRUE if the month value is valid. The 12 #GDateMonth enumeration values are the only valid months.

    Parameters

    Returns boolean

  • Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration values are the only valid weekdays.

    Parameters

    Returns boolean

  • date_valid_year(year: number): boolean
  • Returns %TRUE if the year is valid. Any year greater than 0 is valid, though there is a 16-bit limit to what #GDate will understand.

    Parameters

    • year: number

      year

    Returns boolean

  • dcgettext(domain: string, msgid: string, category: number): string
  • This is a variant of g_dgettext() that allows specifying a locale category instead of always using LC_MESSAGES. See g_dgettext() for more information about how this functions differs from calling dcgettext() directly.

    Parameters

    • domain: string

      the translation domain to use, or %NULL to use the domain set with textdomain()

    • msgid: string

      message to translate

    • category: number

      a locale category

    Returns string

  • dgettext(domain: string, msgid: string): string
  • This function is a wrapper of dgettext() which does not translate the message if the default domain as set with textdomain() has no translations for the current locale.

    The advantage of using this function over dgettext() proper is that libraries using this function (like GTK+) will not use translations if the application using the library does not have translations for the current locale. This results in a consistent English-only interface instead of one having partial translations. For this feature to work, the call to textdomain() and setlocale() should precede any g_dgettext() invocations. For GTK+, it means calling textdomain() before gtk_init or its variants.

    This function disables translations if and only if upon its first call all the following conditions hold:

    • domain is not %NULL

    • textdomain() has been called to set a default text domain

    • there is no translations available for the default text domain and the current locale

    • current locale is not "C" or any English locales (those starting with "en_")

    Note that this behavior may not be desired for example if an application has its untranslated messages in a language other than English. In those cases the application should call textdomain() after initializing GTK+.

    Applications should normally not use this function directly, but use the _() macro for translations.

    Parameters

    • domain: string

      the translation domain to use, or %NULL to use the domain set with textdomain()

    • msgid: string

      message to translate

    Returns string

  • dir_make_tmp(tmpl: string): string
  • Creates a subdirectory in the preferred directory for temporary files (as returned by g_get_tmp_dir()).

    tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, as the parameter to g_mkstemp(). However, unlike these functions, the template should only be a basename, no directory components are allowed. If template is %NULL, a default template is used.

    Note that in contrast to g_mkdtemp() (and mkdtemp()) tmpl is not modified, and might thus be a read-only literal string.

    Parameters

    • tmpl: string

      Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template

    Returns string

  • direct_equal(v1: object, v2: object): boolean
  • Compares two #gpointer arguments and returns %TRUE if they are equal. It can be passed to g_hash_table_new() as the key_equal_func parameter, when using opaque pointers compared by pointer value as keys in a #GHashTable.

    This equality function is also appropriate for keys that are integers stored in pointers, such as GINT_TO_POINTER (n).

    Parameters

    • v1: object

      a key

    • v2: object

      a key to compare with v1

    Returns boolean

  • direct_hash(v: object): number
  • Converts a gpointer to a hash value. It can be passed to g_hash_table_new() as the hash_func parameter, when using opaque pointers compared by pointer value as keys in a #GHashTable.

    This hash function is also appropriate for keys that are integers stored in pointers, such as GINT_TO_POINTER (n).

    Parameters

    • v: object

      a #gpointer key

    Returns number

  • dngettext(domain: string, msgid: string, msgid_plural: string, n: number): string
  • This function is a wrapper of dngettext() which does not translate the message if the default domain as set with textdomain() has no translations for the current locale.

    See g_dgettext() for details of how this differs from dngettext() proper.

    Parameters

    • domain: string

      the translation domain to use, or %NULL to use the domain set with textdomain()

    • msgid: string

      message to translate

    • msgid_plural: string

      plural form of the message

    • n: number

      the quantity for which translation is needed

    Returns string

  • double_equal(v1: object, v2: object): boolean
  • Compares the two #gdouble values being pointed to and returns %TRUE if they are equal. It can be passed to g_hash_table_new() as the key_equal_func parameter, when using non-%NULL pointers to doubles as keys in a #GHashTable.

    Parameters

    • v1: object

      a pointer to a #gdouble key

    • v2: object

      a pointer to a #gdouble key to compare with v1

    Returns boolean

  • double_hash(v: object): number
  • Converts a pointer to a #gdouble to a hash value. It can be passed to g_hash_table_new() as the hash_func parameter, It can be passed to g_hash_table_new() as the hash_func parameter, when using non-%NULL pointers to doubles as keys in a #GHashTable.

    Parameters

    • v: object

      a pointer to a #gdouble key

    Returns number

  • dpgettext(domain: string, msgctxtid: string, msgidoffset: number): string
  • This function is a variant of g_dgettext() which supports a disambiguating message context. GNU gettext uses the '\004' character to separate the message context and message id in msgctxtid. If 0 is passed as msgidoffset, this function will fall back to trying to use the deprecated convention of using "|" as a separation character.

    This uses g_dgettext() internally. See that functions for differences with dgettext() proper.

    Applications should normally not use this function directly, but use the C_() macro for translations with context.

    Parameters

    • domain: string

      the translation domain to use, or %NULL to use the domain set with textdomain()

    • msgctxtid: string

      a combined message context and message id, separated by a \004 character

    • msgidoffset: number

      the offset of the message id in msgctxid

    Returns string

  • dpgettext2(domain: string, context: string, msgid: string): string
  • This function is a variant of g_dgettext() which supports a disambiguating message context. GNU gettext uses the '\004' character to separate the message context and message id in msgctxtid.

    This uses g_dgettext() internally. See that functions for differences with dgettext() proper.

    This function differs from C_() in that it is not a macro and thus you may use non-string-literals as context and msgid arguments.

    Parameters

    • domain: string

      the translation domain to use, or %NULL to use the domain set with textdomain()

    • context: string

      the message context

    • msgid: string

      the message

    Returns string

  • environ_getenv(envp: string[], variable: string): string | null
  • Returns the value of the environment variable variable in the provided list envp.

    Parameters

    • envp: string[]

      an environment list (eg, as returned from g_get_environ()), or %NULL for an empty environment list

    • variable: string

      the environment variable to get

    Returns string | null

  • environ_setenv(envp: string[], variable: string, value: string, overwrite: boolean): string[]
  • Sets the environment variable variable in the provided list envp to value.

    Parameters

    • envp: string[]

      an environment list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL for an empty environment list

    • variable: string

      the environment variable to set, must not contain '='

    • value: string

      the value for to set the variable to

    • overwrite: boolean

      whether to change the variable if it already exists

    Returns string[]

  • environ_unsetenv(envp: string[], variable: string): string[]
  • Removes the environment variable variable from the provided environment envp.

    Parameters

    • envp: string[]

      an environment list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL for an empty environment list

    • variable: string

      the environment variable to remove, must not contain '='

    Returns string[]

  • Gets a #GFileError constant based on the passed-in err_no.

    For example, if you pass in EEXIST this function returns %G_FILE_ERROR_EXIST. Unlike errno values, you can portably assume that all #GFileError values will exist.

    Normally a #GFileError value goes into a #GError returned from a function that manipulates files. So you would use g_file_error_from_errno() when constructing a #GError.

    Parameters

    • err_no: number

      an "errno" value

    Returns GLib.FileError

  • file_error_quark(): Quark
  • file_get_contents(filename: string): [boolean, Uint8Array]
  • Reads an entire file into allocated memory, with good error checking.

    If the call was successful, it returns %TRUE and sets contents to the file contents and length to the length of the file contents in bytes. The string stored in contents will be nul-terminated, so for text files you can pass %NULL for the length argument. If the call was not successful, it returns %FALSE and sets error. The error domain is %G_FILE_ERROR. Possible error codes are those in the #GFileError enumeration. In the error case, contents is set to %NULL and length is set to zero.

    Parameters

    • filename: string

      name of a file to read contents from, in the GLib file name encoding

    Returns [boolean, Uint8Array]

  • file_open_tmp(tmpl: string): [number, string]
  • Opens a file for writing in the preferred directory for temporary files (as returned by g_get_tmp_dir()).

    tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, as the parameter to g_mkstemp(). However, unlike these functions, the template should only be a basename, no directory components are allowed. If template is %NULL, a default template is used.

    Note that in contrast to g_mkstemp() (and mkstemp()) tmpl is not modified, and might thus be a read-only literal string.

    Upon success, and if name_used is non-%NULL, the actual name used is returned in name_used. This string should be freed with g_free() when not needed any longer. The returned name is in the GLib file name encoding.

    Parameters

    • tmpl: string

      Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template

    Returns [number, string]

  • file_read_link(filename: string): string
  • Reads the contents of the symbolic link filename like the POSIX readlink() function. The returned string is in the encoding used for filenames. Use g_filename_to_utf8() to convert it to UTF-8.

    Parameters

    • filename: string

      the symbolic link

    Returns string

  • file_set_contents(filename: string, contents: Uint8Array): boolean
  • Writes all of contents to a file named filename. This is a convenience wrapper around calling g_file_set_contents_full() with flags set to G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING and mode set to 0666.

    Parameters

    • filename: string

      name of a file to write contents to, in the GLib file name encoding

    • contents: Uint8Array

      string to write to the file

    Returns boolean

  • file_set_contents_full(filename: string, contents: Uint8Array, flags: FileSetContentsFlags, mode: number): boolean
  • Writes all of contents to a file named filename, with good error checking. If a file called filename already exists it will be overwritten.

    flags control the properties of the write operation: whether it’s atomic, and what the tradeoff is between returning quickly or being resilient to system crashes.

    As this function performs file I/O, it is recommended to not call it anywhere where blocking would cause problems, such as in the main loop of a graphical application. In particular, if flags has any value other than %G_FILE_SET_CONTENTS_NONE then this function may call fsync().

    If %G_FILE_SET_CONTENTS_CONSISTENT is set in flags, the operation is atomic in the sense that it is first written to a temporary file which is then renamed to the final name.

    Notes:

    • On UNIX, if filename already exists hard links to filename will break. Also since the file is recreated, existing permissions, access control lists, metadata etc. may be lost. If filename is a symbolic link, the link itself will be replaced, not the linked file.

    • On UNIX, if filename already exists and is non-empty, and if the system supports it (via a journalling filesystem or equivalent), and if %G_FILE_SET_CONTENTS_CONSISTENT is set in flags, the fsync() call (or equivalent) will be used to ensure atomic replacement: filename will contain either its old contents or contents, even in the face of system power loss, the disk being unsafely removed, etc.

    • On UNIX, if filename does not already exist or is empty, there is a possibility that system power loss etc. after calling this function will leave filename empty or full of NUL bytes, depending on the underlying filesystem, unless %G_FILE_SET_CONTENTS_DURABLE and %G_FILE_SET_CONTENTS_CONSISTENT are set in flags.

    • On Windows renaming a file will not remove an existing file with the new name, so on Windows there is a race condition between the existing file being removed and the temporary file being renamed.

    • On Windows there is no way to remove a file that is open to some process, or mapped into memory. Thus, this function will fail if filename already exists and is open.

    If the call was successful, it returns %TRUE. If the call was not successful, it returns %FALSE and sets error. The error domain is %G_FILE_ERROR. Possible error codes are those in the #GFileError enumeration.

    Note that the name for the temporary file is constructed by appending up to 7 characters to filename.

    If the file didn’t exist before and is created, it will be given the permissions from mode. Otherwise, the permissions of the existing file may be changed to mode depending on flags, or they may remain unchanged.

    Parameters

    • filename: string

      name of a file to write contents to, in the GLib file name encoding

    • contents: Uint8Array

      string to write to the file

    • flags: FileSetContentsFlags

      flags controlling the safety vs speed of the operation

    • mode: number

      file mode, as passed to open(); typically this will be 0666

    Returns boolean

  • file_test(filename: string, test: FileTest): boolean
  • Returns %TRUE if any of the tests in the bitfield test are %TRUE. For example, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) will return %TRUE if the file exists; the check whether it's a directory doesn't matter since the existence test is %TRUE. With the current set of available tests, there's no point passing in more than one test at a time.

    Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links, so for a symbolic link to a regular file g_file_test() will return %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.

    Note, that for a dangling symbolic link g_file_test() will return %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.

    You should never use g_file_test() to test whether it is safe to perform an operation, because there is always the possibility of the condition changing before you actually perform the operation. For example, you might think you could use %G_FILE_TEST_IS_SYMLINK to know whether it is safe to write to a file without being tricked into writing into a different location. It doesn't work!

     // DON'T DO THIS
    if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
    {
    fd = g_open (filename, O_WRONLY);
    // write to fd
    }

    Another thing to note is that %G_FILE_TEST_EXISTS and %G_FILE_TEST_IS_EXECUTABLE are implemented using the access() system call. This usually doesn't matter, but if your program is setuid or setgid it means that these tests will give you the answer for the real user ID and group ID, rather than the effective user ID and group ID.

    On Windows, there are no symlinks, so testing for %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and its name indicates that it is executable, checking for well-known extensions and those listed in the PATHEXT environment variable.

    Parameters

    • filename: string

      a filename to test in the GLib file name encoding

    • test: FileTest

      bitfield of #GFileTest flags

    Returns boolean

  • filename_display_basename(filename: string): string
  • Returns the display basename for the particular filename, guaranteed to be valid UTF-8. The display name might not be identical to the filename, for instance there might be problems converting it to UTF-8, and some files can be translated in the display.

    If GLib cannot make sense of the encoding of filename, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character. You can search the result for the UTF-8 encoding of this character (which is "\357\277\275" in octal notation) to find out if filename was in an invalid encoding.

    You must pass the whole absolute pathname to this functions so that translation of well known locations can be done.

    This function is preferred over g_filename_display_name() if you know the whole path, as it allows translation.

    Parameters

    • filename: string

      an absolute pathname in the GLib file name encoding

    Returns string

  • filename_display_name(filename: string): string
  • Converts a filename into a valid UTF-8 string. The conversion is not necessarily reversible, so you should keep the original around and use the return value of this function only for display purposes. Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL even if the filename actually isn't in the GLib file name encoding.

    If GLib cannot make sense of the encoding of filename, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character. You can search the result for the UTF-8 encoding of this character (which is "\357\277\275" in octal notation) to find out if filename was in an invalid encoding.

    If you know the whole pathname of the file you should use g_filename_display_basename(), since that allows location-based translation of filenames.

    Parameters

    • filename: string

      a pathname hopefully in the GLib file name encoding

    Returns string

  • filename_from_uri(uri: string): [string, string | null]
  • Converts an escaped ASCII-encoded URI to a local filename in the encoding used for filenames.

    Parameters

    • uri: string

      a uri describing a filename (escaped, encoded in ASCII).

    Returns [string, string | null]

  • filename_from_utf8(utf8string: string, len: number): [string, number, number]
  • Converts a string from UTF-8 to the encoding GLib uses for filenames. Note that on Windows GLib uses UTF-8 for filenames; on other platforms, this function indirectly depends on the [current locale][setlocale].

    The input string shall not contain nul characters even if the len argument is positive. A nul character found inside the string will result in error %G_CONVERT_ERROR_ILLEGAL_SEQUENCE. If the filename encoding is not UTF-8 and the conversion output contains a nul character, the error %G_CONVERT_ERROR_EMBEDDED_NUL is set and the function returns %NULL.

    Parameters

    • utf8string: string

      a UTF-8 encoded string.

    • len: number

      the length of the string, or -1 if the string is nul-terminated.

    Returns [string, number, number]

  • filename_to_uri(filename: string, hostname: string): string
  • Converts an absolute filename to an escaped ASCII-encoded URI, with the path component following Section 3.3. of RFC 2396.

    Parameters

    • filename: string

      an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows

    • hostname: string

      A UTF-8 encoded hostname, or %NULL for none.

    Returns string

  • filename_to_utf8(opsysstring: string, len: number): [string, number, number]
  • Converts a string which is in the encoding used by GLib for filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8 for filenames; on other platforms, this function indirectly depends on the [current locale][setlocale].

    The input string shall not contain nul characters even if the len argument is positive. A nul character found inside the string will result in error %G_CONVERT_ERROR_ILLEGAL_SEQUENCE. If the source encoding is not UTF-8 and the conversion output contains a nul character, the error %G_CONVERT_ERROR_EMBEDDED_NUL is set and the function returns %NULL. Use g_convert() to produce output that may contain embedded nul characters.

    Parameters

    • opsysstring: string

      a string in the encoding for filenames

    • len: number

      the length of the string, or -1 if the string is nul-terminated (Note that some encodings may allow nul bytes to occur inside strings. In that case, using -1 for the len parameter is unsafe)

    Returns [string, number, number]

  • find_program_in_path(program: string): string | null
  • Locates the first executable named program in the user's path, in the same way that execvp() would locate it. Returns an allocated string with the absolute path name, or %NULL if the program is not found in the path. If program is already an absolute path, returns a copy of program if program exists and is executable, and %NULL otherwise.

    On Windows, if program does not have a file type suffix, tries with the suffixes .exe, .cmd, .bat and .com, and the suffixes in the PATHEXT environment variable.

    On Windows, it looks for the file in the same way as CreateProcess() would. This means first in the directory where the executing program was loaded from, then in the current directory, then in the Windows 32-bit system directory, then in the Windows directory, and finally in the directories in the PATH environment variable. If the program is found, the return value contains the full name including the type suffix.

    Parameters

    • program: string

      a program name in the GLib file name encoding

    Returns string | null

  • format_size(size: number): string
  • Formats a size (for example the size of a file) into a human readable string. Sizes are rounded to the nearest size prefix (kB, MB, GB) and are displayed rounded to the nearest tenth. E.g. the file size 3292528 bytes will be converted into the string "3.2 MB". The returned string is UTF-8, and may use a non-breaking space to separate the number and units, to ensure they aren’t separated when line wrapped.

    The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).

    This string should be freed with g_free() when not needed any longer.

    See g_format_size_full() for more options about how the size might be formatted.

    Parameters

    • size: number

      a size in bytes

    Returns string

  • format_size_for_display(size: number): string
  • Formats a size (for example the size of a file) into a human readable string. Sizes are rounded to the nearest size prefix (KB, MB, GB) and are displayed rounded to the nearest tenth. E.g. the file size 3292528 bytes will be converted into the string "3.1 MB".

    The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).

    This string should be freed with g_free() when not needed any longer.

    Parameters

    • size: number

      a size in bytes

    Returns string

  • Formats a size.

    This function is similar to g_format_size() but allows for flags that modify the output. See #GFormatSizeFlags.

    Parameters

    • size: number

      a size in bytes

    • flags: FormatSizeFlags

      #GFormatSizeFlags to modify the output

    Returns string

  • free(mem: object): void
  • Frees the memory pointed to by mem.

    If mem is %NULL it simply returns, so there is no need to check mem against %NULL before calling this function.

    Parameters

    • mem: object

      the memory to free

    Returns void

  • get_application_name(): string | null
  • Gets a human-readable name for the application, as set by g_set_application_name(). This name should be localized if possible, and is intended for display to the user. Contrast with g_get_prgname(), which gets a non-localized name. If g_set_application_name() has not been called, returns the result of g_get_prgname() (which may be %NULL if g_set_prgname() has also not been called).

    Returns string | null

  • get_charset(): [boolean, string]
  • Obtains the character set for the [current locale][setlocale]; you might use this character set as an argument to g_convert(), to convert from the current locale's encoding to some other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8() are nice shortcuts, though.)

    On Windows the character set returned by this function is the so-called system default ANSI code-page. That is the character set used by the "narrow" versions of C library and Win32 functions that handle file names. It might be different from the character set used by the C library's current locale.

    On Linux, the character set is found by consulting nl_langinfo() if available. If not, the environment variables LC_ALL, LC_CTYPE, LANG and CHARSET are queried in order.

    The return value is %TRUE if the locale's encoding is UTF-8, in that case you can perhaps avoid calling g_convert().

    The string returned in charset is not allocated, and should not be freed.

    Returns [boolean, string]

  • get_codeset(): string
  • get_console_charset(): [boolean, string]
  • Obtains the character set used by the console attached to the process, which is suitable for printing output to the terminal.

    Usually this matches the result returned by g_get_charset(), but in environments where the locale's character set does not match the encoding of the console this function tries to guess a more suitable value instead.

    On Windows the character set returned by this function is the output code page used by the console associated with the calling process. If the codepage can't be determined (for example because there is no console attached) UTF-8 is assumed.

    The return value is %TRUE if the locale's encoding is UTF-8, in that case you can perhaps avoid calling g_convert().

    The string returned in charset is not allocated, and should not be freed.

    Returns [boolean, string]

  • get_current_dir(): string
  • Gets the current directory.

    The returned string should be freed when no longer needed. The encoding of the returned string is system defined. On Windows, it is always UTF-8.

    Since GLib 2.40, this function will return the value of the "PWD" environment variable if it is set and it happens to be the same as the current directory. This can make a difference in the case that the current directory is the target of a symbolic link.

    Returns string

  • get_current_time(result: TimeVal): void
  • Equivalent to the UNIX gettimeofday() function, but portable.

    You may find g_get_real_time() to be more convenient.

    Parameters

    • result: TimeVal

      #GTimeVal structure in which to store current time.

    Returns void

  • get_environ(): string[]
  • Gets the list of environment variables for the current process.

    The list is %NULL terminated and each item in the list is of the form 'NAME=VALUE'.

    This is equivalent to direct access to the 'environ' global variable, except portable.

    The return value is freshly allocated and it should be freed with g_strfreev() when it is no longer needed.

    Returns string[]

  • get_filename_charsets(): [boolean, string[]]
  • Determines the preferred character sets used for filenames. The first character set from the charsets is the filename encoding, the subsequent character sets are used when trying to generate a displayable representation of a filename, see g_filename_display_name().

    On Unix, the character sets are determined by consulting the environment variables G_FILENAME_ENCODING and G_BROKEN_FILENAMES. On Windows, the character set used in the GLib API is always UTF-8 and said environment variables have no effect.

    G_FILENAME_ENCODING may be set to a comma-separated list of character set names. The special token "`locale"is taken to mean the character set for the [current locale][setlocale]. IfG_FILENAME_ENCODINGis not set, butG_BROKEN_FILENAMES` is, the character set of the current locale is taken as the filename encoding. If neither environment variable is set, UTF-8 is taken as the filename encoding, but the character set of the current locale is also put in the list of encodings.

    The returned charsets belong to GLib and must not be freed.

    Note that on Unix, regardless of the locale character set or G_FILENAME_ENCODING value, the actual file names present on a system might be in any random encoding or just gibberish.

    Returns [boolean, string[]]

  • get_home_dir(): string
  • Gets the current user's home directory.

    As with most UNIX tools, this function will return the value of the HOME environment variable if it is set to an existing absolute path name, falling back to the passwd file in the case that it is unset.

    If the path given in HOME is non-absolute, does not exist, or is not a directory, the result is undefined.

    Before version 2.36 this function would ignore the HOME environment variable, taking the value from the passwd database instead. This was changed to increase the compatibility of GLib with other programs (and the XDG basedir specification) and to increase testability of programs based on GLib (by making it easier to run them from test frameworks).

    If your program has a strong requirement for either the new or the old behaviour (and if you don't wish to increase your GLib dependency to ensure that the new behaviour is in effect) then you should either directly check the HOME environment variable yourself or unset it before calling any functions in GLib.

    Returns string

  • get_host_name(): string
  • Return a name for the machine.

    The returned name is not necessarily a fully-qualified domain name, or even present in DNS or some other name service at all. It need not even be unique on your local network or site, but usually it is. Callers should not rely on the return value having any specific properties like uniqueness for security purposes. Even if the name of the machine is changed while an application is running, the return value from this function does not change. The returned string is owned by GLib and should not be modified or freed. If no name can be determined, a default fixed string "localhost" is returned.

    The encoding of the returned string is UTF-8.

    Returns string

  • get_language_names(): string[]
  • Computes a list of applicable locale names, which can be used to e.g. construct locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable and always contains the default locale "C".

    For example, if LANGUAGE=de:en_US, then the returned list is "de", "en_US", "en", "C".

    This function consults the environment variables LANGUAGE, LC_ALL, LC_MESSAGES and LANG to find the list of locales specified by the user.

    Returns string[]

  • get_language_names_with_category(category_name: string): string[]
  • Computes a list of applicable locale names with a locale category name, which can be used to construct the fallback locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable and always contains the default locale "C".

    This function consults the environment variables LANGUAGE, LC_ALL, category_name, and LANG to find the list of locales specified by the user.

    g_get_language_names() returns g_get_language_names_with_category("LC_MESSAGES").

    Parameters

    • category_name: string

      a locale category name

    Returns string[]

  • get_locale_variants(locale: string): string[]
  • Returns a list of derived variants of locale, which can be used to e.g. construct locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable. This function handles territory, charset and extra locale modifiers. See setlocale(3) for information about locales and their format.

    locale itself is guaranteed to be returned in the output.

    For example, if locale is fr_BE, then the returned list is fr_BE, fr. If locale is en_GB.UTF-8euro, then the returned list is `en_GB.UTF-8`euro, en_GB.UTF-8, en_GBeuro, `en_GB`, `en.UTF-8`euro, en.UTF-8, eneuro``, en.

    If you need the list of variants for the current locale, use g_get_language_names().

    Parameters

    • locale: string

      a locale identifier

    Returns string[]

  • get_monotonic_time(): number
  • Queries the system monotonic time.

    The monotonic clock will always increase and doesn't suffer discontinuities when the user (or NTP) changes the system time. It may or may not continue to tick during times where the machine is suspended.

    We try to use the clock that corresponds as closely as possible to the passage of time as measured by system calls such as poll() but it may not always be possible to do this.

    Returns number

  • get_num_processors(): number
  • Determine the approximate number of threads that the system will schedule simultaneously for this process. This is intended to be used as a parameter to g_thread_pool_new() for CPU bound tasks and similar cases.

    Returns number

  • get_os_info(key_name: string): string | null
  • Get information about the operating system.

    On Linux this comes from the /etc/os-release file. On other systems, it may come from a variety of sources. You can either use the standard key names like %G_OS_INFO_KEY_NAME or pass any UTF-8 string key name. For example, /etc/os-release provides a number of other less commonly used values that may be useful. No key is guaranteed to be provided, so the caller should always check if the result is %NULL.

    Parameters

    • key_name: string

      a key for the OS info being requested, for example %G_OS_INFO_KEY_NAME.

    Returns string | null

  • get_prgname(): string | null
  • Gets the name of the program. This name should not be localized, in contrast to g_get_application_name().

    If you are using #GApplication the program name is set in g_application_run(). In case of GDK or GTK+ it is set in gdk_init(), which is called by gtk_init() and the #GtkApplication::startup handler. The program name is found by taking the last component of argv[0].

    Returns string | null

  • get_real_name(): string
  • Gets the real name of the user. This usually comes from the user's entry in the passwd file. The encoding of the returned string is system-defined. (On Windows, it is, however, always UTF-8.) If the real user name cannot be determined, the string "Unknown" is returned.

    Returns string

  • get_real_time(): number
  • Queries the system wall-clock time.

    This call is functionally equivalent to g_get_current_time() except that the return value is often more convenient than dealing with a #GTimeVal.

    You should only use this call if you are actually interested in the real wall-clock time. g_get_monotonic_time() is probably more useful for measuring intervals.

    Returns number

  • get_system_config_dirs(): string[]
  • Returns an ordered list of base directories in which to access system-wide configuration information.

    On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification. In this case the list of directories retrieved will be XDG_CONFIG_DIRS.

    On Windows it follows XDG Base Directory Specification if XDG_CONFIG_DIRS is defined. If XDG_CONFIG_DIRS is undefined, the directory that contains application data for all users is used instead. A typical path is C:\Documents and Settings\All Users\Application Data. This folder is used for application data that is not user specific. For example, an application can store a spell-check dictionary, a database of clip art, or a log file in the FOLDERID_ProgramData folder. This information will not roam and is available to anyone using the computer.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string[]

  • get_system_data_dirs(): string[]
  • Returns an ordered list of base directories in which to access system-wide application data.

    On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification In this case the list of directories retrieved will be XDG_DATA_DIRS.

    On Windows it follows XDG Base Directory Specification if XDG_DATA_DIRS is defined. If XDG_DATA_DIRS is undefined, the first elements in the list are the Application Data and Documents folders for All Users. (These can be determined only on Windows 2000 or later and are not present in the list on other Windows versions.) See documentation for FOLDERID_ProgramData and FOLDERID_PublicDocuments.

    Then follows the "share" subfolder in the installation folder for the package containing the DLL that calls this function, if it can be determined.

    Finally the list contains the "share" subfolder in the installation folder for GLib, and in the installation folder for the package the application's .exe file belongs to.

    The installation folders above are determined by looking up the folder where the module (DLL or EXE) in question is located. If the folder's name is "bin", its parent is used, otherwise the folder itself.

    Note that on Windows the returned list can vary depending on where this function is called.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string[]

  • get_tmp_dir(): string
  • Gets the directory to use for temporary files.

    On UNIX, this is taken from the TMPDIR environment variable. If the variable is not set, P_tmpdir is used, as defined by the system C library. Failing that, a hard-coded default of "/tmp" is returned.

    On Windows, the TEMP environment variable is used, with the root directory of the Windows installation (eg: "C:") used as a default.

    The encoding of the returned string is system-defined. On Windows, it is always UTF-8. The return value is never %NULL or the empty string.

    Returns string

  • get_user_cache_dir(): string
  • Returns a base directory in which to store non-essential, cached data specific to particular user.

    On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification. In this case the directory retrieved will be XDG_CACHE_HOME.

    On Windows it follows XDG Base Directory Specification if XDG_CACHE_HOME is defined. If XDG_CACHE_HOME is undefined, the directory that serves as a common repository for temporary Internet files is used instead. A typical path is C:\Documents and Settings\username\Local Settings\Temporary Internet Files. See the documentation for FOLDERID_InternetCache.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string

  • get_user_config_dir(): string
  • Returns a base directory in which to store user-specific application configuration information such as user preferences and settings.

    On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification. In this case the directory retrieved will be XDG_CONFIG_HOME.

    On Windows it follows XDG Base Directory Specification if XDG_CONFIG_HOME is defined. If XDG_CONFIG_HOME is undefined, the folder to use for local (as opposed to roaming) application data is used instead. See the documentation for FOLDERID_LocalAppData. Note that in this case on Windows it will be the same as what g_get_user_data_dir() returns.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string

  • get_user_data_dir(): string
  • Returns a base directory in which to access application data such as icons that is customized for a particular user.

    On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification. In this case the directory retrieved will be XDG_DATA_HOME.

    On Windows it follows XDG Base Directory Specification if XDG_DATA_HOME is defined. If XDG_DATA_HOME is undefined, the folder to use for local (as opposed to roaming) application data is used instead. See the documentation for FOLDERID_LocalAppData. Note that in this case on Windows it will be the same as what g_get_user_config_dir() returns.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string

  • get_user_name(): string
  • Gets the user name of the current user. The encoding of the returned string is system-defined. On UNIX, it might be the preferred file name encoding, or something else, and there is no guarantee that it is even consistent on a machine. On Windows, it is always UTF-8.

    Returns string

  • get_user_runtime_dir(): string
  • Returns a directory that is unique to the current user on the local system.

    This is determined using the mechanisms described in the XDG Base Directory Specification. This is the directory specified in the XDG_RUNTIME_DIR environment variable. In the case that this variable is not set, we return the value of g_get_user_cache_dir(), after verifying that it exists.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string

  • Returns the full path of a special directory using its logical id.

    On UNIX this is done using the XDG special user directories. For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP falls back to $HOME/Desktop when XDG special user directories have not been set up.

    Depending on the platform, the user might be able to change the path of the special directory without requiring the session to restart; GLib will not reflect any change once the special directories are loaded.

    Parameters

    Returns string | null

  • get_user_state_dir(): string
  • Returns a base directory in which to store state files specific to particular user.

    On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification. In this case the directory retrieved will be XDG_STATE_HOME.

    On Windows it follows XDG Base Directory Specification if XDG_STATE_HOME is defined. If XDG_STATE_HOME is undefined, the folder to use for local (as opposed to roaming) application data is used instead. See the documentation for FOLDERID_LocalAppData. Note that in this case on Windows it will be the same as what g_get_user_data_dir() returns.

    The return value is cached and modifying it at runtime is not supported, as it’s not thread-safe to modify environment variables at runtime.

    Returns string

  • getenv(variable: string): string | null
  • Returns the value of an environment variable.

    On UNIX, the name and value are byte strings which might or might not be in some consistent character set and encoding. On Windows, they are in UTF-8. On Windows, in case the environment variable's value contains references to other environment variables, they are expanded.

    Parameters

    • variable: string

      the environment variable to get

    Returns string | null

  • hash_table_add(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • This is a convenience function for using a #GHashTable as a set. It is equivalent to calling g_hash_table_replace() with key as both the key and the value.

    In particular, this means that if key already exists in the hash table, then the old copy of key in the hash table is freed and key replaces it in the table.

    When a hash table only ever contains keys that have themselves as the corresponding value it is able to be stored more efficiently. See the discussion in the section description.

    Starting from GLib 2.40, this function returns a boolean value to indicate whether the newly added value was already in the hash table or not.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      a key to insert

    Returns boolean

  • hash_table_contains(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • Checks if key is in hash_table.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      a key to check

    Returns boolean

  • hash_table_destroy(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Destroys all keys and values in the #GHashTable and decrements its reference count by 1. If keys and/or values are dynamically allocated, you should either free them first or create the #GHashTable with destroy notifiers using g_hash_table_new_full(). In the latter case the destroy functions you supplied will be called on all keys and values during the destruction phase.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    Returns void

  • hash_table_insert(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object, value: object): boolean
  • Inserts a new key and value into a #GHashTable.

    If the key already exists in the #GHashTable its current value is replaced with the new value. If you supplied a value_destroy_func when creating the #GHashTable, the old value is freed using that function. If you supplied a key_destroy_func when creating the #GHashTable, the passed key is freed using that function.

    Starting from GLib 2.40, this function returns a boolean value to indicate whether the newly added value was already in the hash table or not.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      a key to insert

    • value: object

      the value to associate with the key

    Returns boolean

  • hash_table_lookup(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): object | null
  • Looks up a key in a #GHashTable. Note that this function cannot distinguish between a key that is not present and one which is present and has the value %NULL. If you need this distinction, use g_hash_table_lookup_extended().

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      the key to look up

    Returns object | null

  • hash_table_lookup_extended(hash_table: HashTable<string | number | symbol, string | number | boolean>, lookup_key: object): [boolean, object | null, object | null]
  • Looks up a key in the #GHashTable, returning the original key and the associated value and a #gboolean which is %TRUE if the key was found. This is useful if you need to free the memory allocated for the original key, for example before calling g_hash_table_remove().

    You can actually pass %NULL for lookup_key to test whether the %NULL key exists, provided the hash and equal functions of hash_table are %NULL-safe.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • lookup_key: object

      the key to look up

    Returns [boolean, object | null, object | null]

  • hash_table_new_similar(other_hash_table: HashTable<string | number | symbol, string | number | boolean>): HashTable
  • Creates a new #GHashTable like g_hash_table_new_full() with a reference count of 1.

    It inherits the hash function, the key equal function, the key destroy function, as well as the value destroy function, from other_hash_table.

    The returned hash table will be empty; it will not contain the keys or values from other_hash_table.

    Parameters

    • other_hash_table: HashTable<string | number | symbol, string | number | boolean>

      Another #GHashTable

    Returns HashTable

  • hash_table_remove(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • Removes a key and its associated value from a #GHashTable.

    If the #GHashTable was created using g_hash_table_new_full(), the key and value are freed using the supplied destroy functions, otherwise you have to make sure that any dynamically allocated values are freed yourself.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      the key to remove

    Returns boolean

  • hash_table_remove_all(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Removes all keys and their associated values from a #GHashTable.

    If the #GHashTable was created using g_hash_table_new_full(), the keys and values are freed using the supplied destroy functions, otherwise you have to make sure that any dynamically allocated values are freed yourself.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    Returns void

  • hash_table_replace(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object, value: object): boolean
  • Inserts a new key and value into a #GHashTable similar to g_hash_table_insert(). The difference is that if the key already exists in the #GHashTable, it gets replaced by the new key. If you supplied a value_destroy_func when creating the #GHashTable, the old value is freed using that function. If you supplied a key_destroy_func when creating the #GHashTable, the old key is freed using that function.

    Starting from GLib 2.40, this function returns a boolean value to indicate whether the newly added value was already in the hash table or not.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      a key to insert

    • value: object

      the value to associate with the key

    Returns boolean

  • hash_table_size(hash_table: HashTable<string | number | symbol, string | number | boolean>): number
  • Returns the number of elements contained in the #GHashTable.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    Returns number

  • hash_table_steal(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • Removes a key and its associated value from a #GHashTable without calling the key and value destroy functions.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • key: object

      the key to remove

    Returns boolean

  • hash_table_steal_all(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Removes all keys and their associated values from a #GHashTable without calling the key and value destroy functions.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    Returns void

  • hash_table_steal_extended(hash_table: HashTable<string | number | symbol, string | number | boolean>, lookup_key: object): [boolean, object | null, object | null]
  • Looks up a key in the #GHashTable, stealing the original key and the associated value and returning %TRUE if the key was found. If the key was not found, %FALSE is returned.

    If found, the stolen key and value are removed from the hash table without calling the key and value destroy functions, and ownership is transferred to the caller of this method; as with g_hash_table_steal().

    You can pass %NULL for lookup_key, provided the hash and equal functions of hash_table are %NULL-safe.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    • lookup_key: object

      the key to look up

    Returns [boolean, object | null, object | null]

  • hash_table_unref(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Atomically decrements the reference count of hash_table by one. If the reference count drops to 0, all keys and values will be destroyed, and all memory allocated by the hash table is released. This function is MT-safe and may be called from any thread.

    Parameters

    • hash_table: HashTable<string | number | symbol, string | number | boolean>

      a valid #GHashTable

    Returns void

  • hook_destroy(hook_list: HookList, hook_id: number): boolean
  • Removes one #GHook from a #GHookList, marking it inactive and calling g_hook_unref() on it.

    Parameters

    Returns void

  • Calls the #GHookList finalize_hook function if it exists, and frees the memory allocated for the #GHook.

    Parameters

    Returns void

  • Decrements the reference count of a #GHook. If the reference count falls to 0, the #GHook is removed from the #GHookList and g_hook_free() is called to free it.

    Parameters

    Returns void

  • hostname_is_ascii_encoded(hostname: string): boolean
  • Tests if hostname contains segments with an ASCII-compatible encoding of an Internationalized Domain Name. If this returns %TRUE, you should decode the hostname with g_hostname_to_unicode() before displaying it to the user.

    Note that a hostname might contain a mix of encoded and unencoded segments, and so it is possible for g_hostname_is_non_ascii() and g_hostname_is_ascii_encoded() to both return %TRUE for a name.

    Parameters

    • hostname: string

      a hostname

    Returns boolean

  • hostname_is_ip_address(hostname: string): boolean
  • Tests if hostname is the string form of an IPv4 or IPv6 address. (Eg, "192.168.0.1".)

    Since 2.66, IPv6 addresses with a zone-id are accepted (RFC6874).

    Parameters

    • hostname: string

      a hostname (or IP address in string form)

    Returns boolean

  • hostname_is_non_ascii(hostname: string): boolean
  • Tests if hostname contains Unicode characters. If this returns %TRUE, you need to encode the hostname with g_hostname_to_ascii() before using it in non-IDN-aware contexts.

    Note that a hostname might contain a mix of encoded and unencoded segments, and so it is possible for g_hostname_is_non_ascii() and g_hostname_is_ascii_encoded() to both return %TRUE for a name.

    Parameters

    • hostname: string

      a hostname

    Returns boolean

  • hostname_to_ascii(hostname: string): string | null
  • Converts hostname to its canonical ASCII form; an ASCII-only string containing no uppercase letters and not ending with a trailing dot.

    Parameters

    • hostname: string

      a valid UTF-8 or ASCII hostname

    Returns string | null

  • hostname_to_unicode(hostname: string): string | null
  • Converts hostname to its canonical presentation form; a UTF-8 string in Unicode normalization form C, containing no uppercase letters, no forbidden characters, and no ASCII-encoded segments, and not ending with a trailing dot.

    Of course if hostname is not an internationalized hostname, then the canonical presentation form will be entirely ASCII.

    Parameters

    • hostname: string

      a valid UTF-8 or ASCII hostname

    Returns string | null

  • idle_add(priority: number, function_: SourceFunc): number
  • Adds a function to be called whenever there are no higher priority events pending.

    If the function returns %G_SOURCE_REMOVE or %FALSE it is automatically removed from the list of event sources and will not be called again.

    See [memory management of sources][mainloop-memory-management] for details on how to handle the return value and memory management of data.

    This internally creates a main loop source using g_idle_source_new() and attaches it to the global #GMainContext using g_source_attach(), so the callback will be invoked in whichever thread is running that main context. You can do these steps manually if you need greater control or to use a custom main context.

    Parameters

    • priority: number

      the priority of the idle source. Typically this will be in the range between %G_PRIORITY_DEFAULT_IDLE and %G_PRIORITY_HIGH_IDLE.

    • function_: SourceFunc

      function to call

    Returns number

  • idle_remove_by_data(data: object): boolean
  • Removes the idle function with the given data.

    Parameters

    • data: object

      the data for the idle source's callback.

    Returns boolean

  • Creates a new idle source.

    The source will not initially be associated with any #GMainContext and must be added to one with g_source_attach() before it will be executed. Note that the default priority for idle sources is %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which have a default priority of %G_PRIORITY_DEFAULT.

    Returns GLib.Source

  • int64_equal(v1: object, v2: object): boolean
  • Compares the two #gint64 values being pointed to and returns %TRUE if they are equal. It can be passed to g_hash_table_new() as the key_equal_func parameter, when using non-%NULL pointers to 64-bit integers as keys in a #GHashTable.

    Parameters

    • v1: object

      a pointer to a #gint64 key

    • v2: object

      a pointer to a #gint64 key to compare with v1

    Returns boolean

  • int64_hash(v: object): number
  • Converts a pointer to a #gint64 to a hash value.

    It can be passed to g_hash_table_new() as the hash_func parameter, when using non-%NULL pointers to 64-bit integer values as keys in a #GHashTable.

    Parameters

    • v: object

      a pointer to a #gint64 key

    Returns number

  • int_equal(v1: object, v2: object): boolean
  • Compares the two #gint values being pointed to and returns %TRUE if they are equal. It can be passed to g_hash_table_new() as the key_equal_func parameter, when using non-%NULL pointers to integers as keys in a #GHashTable.

    Note that this function acts on pointers to #gint, not on #gint directly: if your hash table's keys are of the form GINT_TO_POINTER (n), use g_direct_equal() instead.

    Parameters

    • v1: object

      a pointer to a #gint key

    • v2: object

      a pointer to a #gint key to compare with v1

    Returns boolean

  • int_hash(v: object): number
  • Converts a pointer to a #gint to a hash value. It can be passed to g_hash_table_new() as the hash_func parameter, when using non-%NULL pointers to integer values as keys in a #GHashTable.

    Note that this function acts on pointers to #gint, not on #gint directly: if your hash table's keys are of the form GINT_TO_POINTER (n), use g_direct_hash() instead.

    Parameters

    • v: object

      a pointer to a #gint key

    Returns number

  • intern_static_string(string: string): string
  • Returns a canonical representation for string. Interned strings can be compared for equality by comparing the pointers, instead of using strcmp(). g_intern_static_string() does not copy the string, therefore string must not be freed or modified.

    This function must not be used before library constructors have finished running. In particular, this means it cannot be used to initialize global variables in C++.

    Parameters

    • string: string

      a static string

    Returns string

  • intern_string(string: string): string
  • Returns a canonical representation for string. Interned strings can be compared for equality by comparing the pointers, instead of using strcmp().

    This function must not be used before library constructors have finished running. In particular, this means it cannot be used to initialize global variables in C++.

    Parameters

    • string: string

      a string

    Returns string

  • Adds the #GIOChannel into the default main loop context with the given priority.

    This internally creates a main loop source using g_io_create_watch() and attaches it to the main loop context with g_source_attach(). You can do these steps manually if you need greater control.

    Parameters

    • channel: IOChannel

      a #GIOChannel

    • priority: number

      the priority of the #GIOChannel source

    • condition: IOCondition

      the condition to watch for

    • func: IOFunc

      the function to call when the condition is satisfied

    Returns number

  • io_channel_error_quark(): Quark
  • io_create_watch(channel: IOChannel, condition: