Skip to content
Snippets Groups Projects
Commit 4cffc059 authored by Robert Stefanic's avatar Robert Stefanic Committed by Alexander Schwinn
Browse files

Support for variables like $HOME in address bar (Bug #12165)

Appending a path to the variable is as well supported.
parent bd19aaaa
No related branches found
No related tags found
1 merge request!6Added the expansion of "$HOME" in address bar (Bug #12165)
Pipeline #230 passed
......@@ -270,6 +270,7 @@ thunar_util_expand_filename (const gchar *filename,
const gchar *slash;
gchar *username;
gchar *pwd;
gchar *variable;
gchar *result = NULL;
g_return_val_if_fail (filename != NULL, NULL);
......@@ -320,6 +321,25 @@ thunar_util_expand_filename (const gchar *filename,
replacement = passwd->pw_dir;
}
/* generate the filename */
return g_build_filename (replacement, slash, NULL);
}
else if (*filename == '$')
{
/* examine the remainder of the variable and filename */
remainder = filename + 1;
/* lookup the slash at the end of the variable */
for (slash = remainder; *slash != '\0' && *slash != G_DIR_SEPARATOR; ++slash);
/* get the variable for replacement */
variable = g_strndup (remainder, slash - remainder);
replacement = g_getenv (variable);
g_free (variable);
if (replacement == NULL)
return NULL;
/* generate the filename */
return g_build_filename (replacement, slash, NULL);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment