### Function

# GLib rename

since: 2.6

#### Declaration

    int
    g_rename (
      const gchar* oldfilename,
      const gchar* newfilename
    )

#### Description

A wrapper for the POSIX `rename()` function. The `rename()` function renames a file, moving it between directories if required.

See your C library manual for more details about how `rename()` works on your system. It is not possible in general on Windows to rename a file that is open to some process.

Available since: 2.6

#### Parameters

`oldfilename`

  Type: `const gchar*`

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

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

`newfilename`

  Type: `const gchar*`

  A pathname in the GLib file name encoding.

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

#### Return value

Type: `int`

0 if the renaming succeeded, -1 if an error occurred.