Пример #1
0
void				normal_build_func(void *data)
{
	DIR				*dirp;
	struct dirent	*info;
	t_data			*fdata;
	t_tree			*tmp;

	info = NULL;
	fdata = NULL;
	if ((print_head_or_dir(data) == 0))
		return ;
	if (!(dirp = opendir((const char *)DATA->path)))
		return (perror(ft_strjoin("ft_ls: ", DATA->name)));
	while ((info = readdir(dirp)) != NULL)
	{
		if ((info->d_name)[0] != '.')
		{
			if (!(fdata = full_data(info, (t_data *)data)))
				return ;
			tmp = ft_create_node_tree((void *)fdata);
			DATA->tree = ft_addnode(DATA->tree, tmp, NULL, DATA->cmp);
		}
	}
	(void)closedir(dirp);
	ft_norme(data, 1);
}
Пример #2
0
void				hide_func(void *data)
{
	DIR				*dirp;
	struct dirent	*info;
	t_data			*fdata;
	t_tree			*tmp;

	info = NULL;
	fdata = NULL;
	ft_init_max(*(DATA->max));
	if (!(dirp = opendir((const char *)DATA->path)))
	{
		perror(ft_strjoin("ft_ls: ", DATA->name));
		return ;
	}
	while ((info = readdir(dirp)) != NULL)
	{
		if (!(fdata = full_data(info, (t_data *)data)))
			return ;
		tmp = ft_create_node_tree((void *)fdata);
		DATA->tree = ft_addnode(DATA->tree, tmp, NULL, DATA->cmp);
	}
	(void)closedir(dirp);
	ft_map_tree(DATA->tree, DATA->print);
	ft_init_max(*(DATA->max));
}
Пример #3
0
std::auto_ptr<Image> WebPFormat::read(byte_source* src, ImageFactory* factory, const options_map& opts) {
    std::vector<byte> data = full_data(*src);
    int w, h;
    int ok = WebPGetInfo(&data[0], data.size(), &w, &h);
    if (!ok) {
        throw CannotReadError("imread.imread._webp: File does not validate as WebP");
    }
    std::auto_ptr<Image> output(factory->create(8, h, w, 4));
    const int stride = w*4;
    const uint8_t* p = WebPDecodeRGBAInto(
            &data[0], data.size(),
            output->rowp_as<byte>(0), h*stride, stride);
    if (p != output->rowp_as<uint8_t>(0)) {
        throw CannotReadError("imread.imread._webp: Error in decoding file");
    }

    return output;
}