PathBuf.setFilename

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);
class PathBuf
bool
setFilename
(
string fileName
)

Parameters

fileName string

the file name in the path

Return Value

Type: bool

TRUE if the file name was replaced, and FALSE otherwise