Beispiel #1
0
int		main(int ac, char **av)
{
	int fd;
	int i;
	int j;

	i = 3;
	if (ac < 4)
		return (0);
	while (i < ac)
	{
		j = -1;
		fd = open(av[i], O_RDONLY);
		if (fd >= 0)
			disp_files(i, fd, ac, av);
		else
		{
			write(2, "ft_tail: ", 9);
			while (av[i][++j])
				write(2, &av[i][j], 1);
			write(2, ": No such file or directory\n", 28);
		}
		close(fd);
		i++;
	}
	return (0);
}
Beispiel #2
0
int		main(int argc, char **argv)
{
	if (argc < 2 || argv[1][0] == '-')
		disp_stdin();
	disp_files(argc, argv);
	return (0);
}
Beispiel #3
0
/*
 * File Select Menu
 */
int file_menu(unsigned int level, unsigned int select)
{
	FRESULT f;
	unsigned int total,offset,num,i;
	unsigned char *items;
	BYTE *attrib;

	f=f_opendir(&dirs, "\0");	// current directory
	switch(f){
		case FR_OK:
			total=0; offset=0; num=0;
			while((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]){
				total++;
			}
			break;
		case FR_INT_ERR:
		case FR_NOT_READY:
		default:
			return(-1);
			break;
	}
	f_readdir(&dirs, (FILINFO *)NULL);	// rewind
	items=malloc(total*13);
	attrib=malloc(total*sizeof(BYTE));
	for(i=0;i<total;i++){
		f_readdir(&dirs, &finfo);
		memcpy(&items[i*13], finfo.fname, 13);
		attrib[i]=finfo.fattrib;
	}

	if(total>23){
		frame(level,23,select);
	}else{
		frame(level,total,select);
	}

	disp_files(level,&items[offset],total);

	MZ_disp(level*13+13,num+1,0x04);
	while(1){
		if((z80_sts.status&S_FBTN)==0){
			free(items); free(attrib);
			return(-1);
		}
		switch(get_key()){
		case 0x08:	// directory back
			MZ_disp(level*13+13,num+1,0x9a);
			f_chdir("..");
			free(items); free(attrib);
			return(file_menu(level,select));
			break;
		case 0x0d:	// select
			MZ_disp(level*13+13,num+1,0x9a);
			if(attrib[offset+num]&AM_DIR){
				f_chdir((TCHAR*)&items[(offset+num)*13]);
				free(items); free(attrib);
				return(file_menu(level,select));
			}else{
				memcpy(fname, &items[(offset+num)*13], 13);
				free(items); free(attrib);
				return(0);
			}
			break;
		case 0x1b:	// escape select
			z80_sts.status&=~S_FBTN;
			break;
		case 0x1d:	// back to menu
			MZ_disp(level*13+13,num+1,0x9a);
			free(items); free(attrib);
			return(999);
			break;
		case 0x1e:	// up
			if(num>0){
				MZ_disp(level*13+13,num,0x04);
				MZ_disp(level*13+13,num+1,0x9a);
				num--;
			}else{
				if(offset>0){
					offset--;
					disp_files(level,&items[offset*13],total);
				}
			}
			break;
		case 0x1f:	// down
			if(total>23){
				if(num<22){
					MZ_disp(level*13+13,num+1,0x9a);
					MZ_disp(level*13+13,num+2,0x04);
					num++;
				}else{
					if((num+offset)<(total-1)){
						offset++;
						disp_files(level,&items[offset*13],total);
					}
				}
			}else{
				if(num<(total-1)){
					MZ_disp(level*13+13,num+1,0x9a);
					MZ_disp(level*13+13,num+2,0x04);
					num++;
				}
			}
			break;
		default:
			break;
		}
	}
	return(-1);
}