diff options
author | John Sullivan <sullivan@src.gnome.org> | 2001-01-18 19:18:52 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2001-01-18 19:18:52 +0000 |
commit | aee3945efe11c38873effaa5aff0121163cd030e (patch) | |
tree | 6e07d5b71a5973a7ad32d745d88cc7bc416f605a /libnautilus-private | |
parent | a3d891380b2544cb99f763e3944bb98b6a52a91e (diff) | |
download | nautilus-aee3945efe11c38873effaa5aff0121163cd030e.tar.gz |
reviewed by: Darin Adler <darin@eazel.com>
* libnautilus-extensions/nautilus-file-utilities.c:
(nautilus_make_uri_from_input):
* libnautilus-extensions/nautilus-link-set.c:
(nautilus_link_set_install):
Used new gnome_vfs_expand_initial_tilde in two places
that were doing this independently (one of which is
where the code for the gnome-vfs routine came from).
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-file-utilities.c | 40 | ||||
-rw-r--r-- | libnautilus-private/nautilus-link-set.c | 15 |
2 files changed, 3 insertions, 52 deletions
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c index 2eb762eed..046d652f5 100644 --- a/libnautilus-private/nautilus-file-utilities.c +++ b/libnautilus-private/nautilus-file-utilities.c @@ -121,38 +121,6 @@ has_valid_scheme (const char *uri) return *p == ':'; } -static char * -expand_tilde (const char *path) -{ - char *slash_after_user_name, *user_name; - struct passwd *passwd_file_entry; - - g_assert (path != NULL); - g_assert (path[0] == '~'); - - if (path[1] == '/' || path[1] == '\0') { - return g_strconcat (g_get_home_dir (), &path[1], NULL); - } - - slash_after_user_name = strchr (&path[1], '/'); - if (slash_after_user_name == NULL) { - user_name = g_strdup (&path[1]); - } else { - user_name = g_strndup (&path[1], - slash_after_user_name - &path[1]); - } - passwd_file_entry = getpwnam (user_name); - g_free (user_name); - - if (passwd_file_entry == NULL || passwd_file_entry->pw_dir == NULL) { - return NULL; - } - - return g_strconcat (passwd_file_entry->pw_dir, - slash_after_user_name, - NULL); -} - /** * nautilus_make_uri_from_input: * @@ -184,12 +152,8 @@ nautilus_make_uri_from_input (const char *location) uri = gnome_vfs_get_uri_from_local_path (stripped); break; case '~': - path = expand_tilde (stripped); - if (path == NULL) { - uri = g_strdup (stripped); - } else { - uri = gnome_vfs_get_uri_from_local_path (path); - } + path = gnome_vfs_expand_initial_tilde (stripped); + uri = gnome_vfs_get_uri_from_local_path (path); g_free (path); break; default: diff --git a/libnautilus-private/nautilus-link-set.c b/libnautilus-private/nautilus-link-set.c index ef7edcce2..9806fa707 100644 --- a/libnautilus-private/nautilus-link-set.c +++ b/libnautilus-private/nautilus-link-set.c @@ -94,19 +94,6 @@ get_link_set_document(const char *link_set_name) return document; } -/* utility to expand the uri to deal with the home directory, etc. */ -static char * -expand_uri (const char *uri) -{ - /* FIXME bugzilla.eazel.com 2487: - * This turns "~x" into "HOME", which is bad. - */ - if (uri[0] == '~') { - return gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); - } - return g_strdup (uri); -} - /* install a link set into the specified directory */ gboolean @@ -133,7 +120,7 @@ nautilus_link_set_install (const char *directory_path, const char *link_set_name uri = xmlGetProp (node, "uri"); /* Expand special URIs */ - full_uri = expand_uri (uri); + full_uri = gnome_vfs_expand_initial_tilde (uri); /* create the link file */ created = create_new_link (directory_path, link_name, |