### Method

# GLib PathBuf set_filename

since: 2.76

#### Declaration

    gboolean
    g_path_buf_set_filename (
      GPathBuf* buf,
      const char* file_name
    )

#### Description

Sets the file name of the path.

If the path buffer is empty, the filename is left unset and this function returns `FALSE`.

If the path buffer only contains the root element (on Unix-like operating systems) or the drive (on Windows), this is the equivalent of pushing the new `file_name`.

If the path buffer contains a path, this is the equivalent of popping the path buffer and pushing `file_name`, creating a sibling of the original path.

    GPathBuf buf, cmp;

    g_path_buf_init_from_path (&buf, "/");

    g_path_buf_set_filename (&buf, "bar");
    g_path_buf_init_from_path (&cmp, "/bar");
    g_assert_true (g_path_buf_equal (&buf, &cmp));
    g_path_buf_clear (&cmp);

    g_path_buf_set_filename (&buf, "baz.txt");
    g_path_buf_init_from_path (&cmp, "/baz.txt");
    g_assert_true (g_path_buf_equal (&buf, &cmp);
    g_path_buf_clear (&cmp);

    g_path_buf_clear (&buf);

Available since: 2.76

#### Parameters

`file_name`

  Type: `const char*`

  The file name in the path.

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

#### Return value

Type: `gboolean`

`TRUE` if the file name was replaced, and `FALSE` otherwise.