Function

GLibmkstemp_full

since: 2.22

Declaration [src]

gint
g_mkstemp_full (
  gchar* tmpl,
  gint flags,
  gint mode
)

Description [src]

Opens a temporary file. See the mkstemp() documentation on most UNIX-like systems.

The parameter is a string that should follow the rules for mkstemp() templates, i.e. contain the string “XXXXXX”. g_mkstemp_full() is slightly more flexible than mkstemp() in that the sequence does not have to occur at the very end of the template and you can pass a mode and additional flags. The X string will be modified to form the name of a file that didn’t exist. The string should be in the GLib file name encoding. Most importantly, on Windows it should be in UTF-8.

Available since: 2.22

This function is not directly available to language bindings.

Parameters

tmpl

Type: gchar*

Template filename.

The data is owned by the caller of the function.
The value is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.
flags

Type: gint

Flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically.

mode

Type: gint

Permissions to create the temporary file with.

Return value

Type: gint

A file handle (as from open()) to the file opened for reading and writing. The file handle should be closed with close(). In case of errors, -1 is returned and %errno will be set.