Exemplo n.º 1
0
Arquivo: dir.c Projeto: sbenning42/42
int					entry_tree(t_node **ar, struct dirent *entry, \
                               quad_t *blocks, int *i)
{
    char			absname[PATHSIZE_LS];
    t_ls_entry		e;
    t_node			*no;

    ft_strcpy(absname, env()->path);
    ft_strcat(absname, "/");
    ft_strcat(absname, entry->d_name);
    e = ls_newentry(entry->d_name, absname);
    if (entry->d_name[0] == '.' && !((env()->o & O_HIDE) == O_HIDE))
        e.handle = 0;
    if (e.handle)
    {
        *i += 1;
        *blocks += e.stat.st_blocks;
    }
    if (!ft_strcmp(entry->d_name, ".") || !ft_strcmp(entry->d_name, ".."))
        e.handle = 0;
    if (!(no = tree_newnode((void *)&e, sizeof(t_ls_entry))))
        return (ft_err(env()->av, absname));
    tree_add(ar, no, g_ls_select_sort(env()->o));
    maj_env(e);
    return (1);
}
Exemplo n.º 2
0
Arquivo: argv.c Projeto: sbenning42/42
static t_node		*argv_wa_tree(int ac, int i, char **av)
{
	int				(*s)(void *, void *);
	t_node			*root;
	t_node			*no;
	t_ls_entry		e;

	root = NULL;
	s = g_ls_select_argvsort(env()->o);
	while (i < ac)
	{
		e = ls_newentry(av[i], av[i]);
		errno = 0;
		if (!(no = tree_newnode((void *)&e, sizeof(t_ls_entry))))
		{
			ft_err(env()->av, av[i]);
			errno = 0;
			tree_del(&root, NULL);
			return (NULL);
		}
		maj_env(e);
		tree_add(&root, no, s);
		i++;
	}
	return (root);
}
Exemplo n.º 3
0
int		do_pwd(t_info *info)
{
  char		*buf;
  char		*res;

  res = NULL;
  buf = NULL;
  res = getcwd(buf, 150);
  if (res != NULL)
    {
      maj_env(info, "PWD", res);
      printf("%s\n", res);
      free(buf);
      free(res);
    }
  return (RETURN_SUCCESS);
}