Exemplo n.º 1
0
void mounts_list_all(void)
{
	struct mount_list *list, *previous;
	int longest = MIN_COL;

	list = collect_active_mounts(&longest);

	if (!list) {
		ERROR("No hugetlbfs mount points found\n");
		return;
	}

	print_mounts(list, longest);

	while (list) {
		previous = list;
		list = list->next;
		free(previous);
	}
}
Exemplo n.º 2
0
Arquivo: gvfs-ls.c Projeto: snnw/gvfs
static void
print_completions (const char *arg)
{
  GFile *f;
  GFile *parent;
  char *basename;
  char *unescaped, *t;
  
  unescaped = g_shell_unquote (arg, NULL);
  if (unescaped == NULL)
    unescaped = g_strdup (arg);
  
  if (*unescaped == '~')
    {
      t = unescaped;
      unescaped = g_strconcat (g_get_home_dir(), t+1, NULL);
      g_free (t);
    }
    
  f = g_file_new_for_commandline_arg (unescaped);
  
  if (g_str_has_suffix (arg, "/") || *arg == 0)
    {
      parent = g_object_ref (f);
      basename = g_strdup ("");
    }
  else
    {
      parent = g_file_get_parent (f);
      basename = g_file_get_basename (f);
    }

  if (parent == NULL ||
      strchr (arg, '/') == NULL ||
      !g_file_query_exists (parent, NULL))
    {
      GMount *mount;
      mount = g_file_find_enclosing_mount (f, NULL, NULL);
      if (mount == NULL)
        print_mounts (unescaped);
      else
        g_object_unref (mount);
    }
  
  if (parent != NULL)
    {
      GFileEnumerator *enumerator;
      enumerator = g_file_enumerate_children (parent, 
                                              G_FILE_ATTRIBUTE_STANDARD_NAME ","
                                              G_FILE_ATTRIBUTE_STANDARD_TYPE,
                                              nofollow_symlinks ? G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS : 0,
                                              NULL, 
                                              NULL);
      if (enumerator != NULL)
        {
          GFileInfo *info;
          
          while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL)
            {
              const char *name;
              GFileType type;
              
              name = g_file_info_get_name (info);
              type = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE);
              if (name != NULL && g_str_has_prefix (name, basename))
                {
                  GFile *entry;
                  
                  entry = g_file_get_child (parent, name);
                  show_completed_file (entry, type == G_FILE_TYPE_DIRECTORY, arg);
                  g_object_unref (entry);
                }
              g_object_unref (info);
            }
          g_file_enumerator_close (enumerator, NULL, NULL);
        }
      g_object_unref (parent);
    }

  g_object_unref (f);
  g_free (basename);
  g_free (unescaped);
}