#include #include #include "aplinks.h" #include "disp_ctr.h" int disp_filelist(unsigned char *fat_buffer[], unsigned char *dir_buffer[], unsigned char *data_buffer[], DIR_RANGE dir_range, int deleted, int ut_dir, int dir_indent) { int cur_dir; int cur_ds_num; int cur_ds_bias; int sec_num; int nfiles; unsigned char fileinfo[32]; cur_dir = 0; nfiles = 0; displist_c_printf(-1, "\n"); displist_c_printf(-1, "L: ¥É¥é¥¤¥Ö¥Õ¥¡¥¤¥ë°ìÍ÷\n"); while(cur_dir < ((dir_range.end - dir_range.start) + 1) * SECTOR_SIZE){ cur_ds_num = cur_dir / SECTOR_SIZE; cur_ds_bias = (cur_dir % SECTOR_SIZE); if(*(dir_buffer[cur_ds_num] + cur_ds_bias) != 0x00){ nfiles++; memcpy(fileinfo, (dir_buffer[cur_ds_num] + cur_ds_bias), 32); disp_fileinfo(fileinfo, deleted, fileinfo[0], fat_buffer, data_buffer); if(fileinfo[ATTR_OFFS] & DIR_ATTR){ nfiles--; sec_num = *(dir_buffer[cur_ds_num] + cur_ds_bias + FAT_LL); sec_num += (*(dir_buffer[cur_ds_num] + cur_ds_bias + FAT_HH) << 8); nfiles += disp_dirinfo(deleted, ut_dir, sec_num, fat_buffer, data_buffer, 1, dir_indent, fileinfo[0]); } cur_dir += 32; } else{ break; } } if(nfiles <= 1){ displist_c_printf(-1, " %d File.\n", nfiles); } else{ displist_c_printf(-1, " %d Files.\n", nfiles); } return nfiles; } int disp_fileinfo(unsigned char fileinfo[], int deleted_show, unsigned char parent_dir_name0, unsigned char *fat_buffer[], unsigned char *data_buffer[]) { int i; int attr; long filesize; unsigned int dateword, timeword; int year, mon, day; int hour, min, sec; int disp_fnc; int disp_atc; int disp_fsc; int disp_fdc; int disp_ftc; int sec_num; int showdate; int showtime; showdate = SHOWDATE; showtime = SHOWTIME; sec_num = fileinfo[FAT_HH]; sec_num = (sec_num << 8) + fileinfo[FAT_LL]; if((fileinfo[0] != 0xe5) && (parent_dir_name0 != 0xe5)){ if(chain_chk(sec_num, fat_buffer, data_buffer) == -1){ disp_fnc = UNCHAIN_COLOR; disp_atc = UNCHAIN_COLOR; disp_fsc = UNCHAIN_COLOR; disp_fdc = UNCHAIN_COLOR; disp_ftc = UNCHAIN_COLOR; } else{ disp_fnc = FILENAME_COLOR; disp_atc = FILEATTR_COLOR; disp_fsc = FILESIZE_COLOR; disp_fdc = FILEDATE_COLOR; disp_ftc = FILETIME_COLOR; } } else{ if(deleted_show == ON){ if(chain_chk(sec_num, fat_buffer, data_buffer) == -1){ disp_fnc = DEL_UNCHAIN_COLOR; disp_atc = DEL_UNCHAIN_COLOR; disp_fsc = DEL_UNCHAIN_COLOR; disp_fdc = DEL_UNCHAIN_COLOR; disp_ftc = DEL_UNCHAIN_COLOR; } else{ disp_fnc = DELETED_COLOR; disp_atc = DELETED_COLOR; disp_fsc = DELETED_COLOR; disp_fdc = DELETED_COLOR; disp_ftc = DELETED_COLOR; } } else{ return 0; } } /* ¥Õ¥¡¥¤¥ë̾¤Îɽ¼¨ */ for(i = 0; i < 8; i++){ displist_c_printf(disp_fnc, "%c", fileinfo[i]); } displist_c_printf(disp_fnc, "."); for(i = 0; i < 3; i++){ displist_c_printf(disp_fnc, "%c", fileinfo[8 + i]); } displist_c_printf(disp_fnc, " "); /* °À­¤Îɽ¼¨ */ attr = fileinfo[ATTR_OFFS]; if(attr & WRI_PROTECT){ displist_c_printf(disp_atc, "P"); } else{ displist_c_printf(disp_atc, "_"); } if(attr & INVISIBLE){ displist_c_printf(disp_atc, "I"); } else{ displist_c_printf(disp_atc, "_"); } if(attr & DEVICEDRV){ displist_c_printf(disp_atc, "D"); } else{ displist_c_printf(disp_atc, "_"); } if(attr & OTHERS){ displist_c_printf(disp_atc, "O"); } else{ displist_c_printf(disp_atc, "_"); } /* ¥Õ¥¡¥¤¥ë¥µ¥¤¥º(¥Ç¥£¥ì¥¯¥È¥ê¤Î¤È¤­¤Ï)¤Îɽ¼¨ */ if(attr & DIR_ATTR){ displist_c_printf(disp_fsc, " "); } else{ filesize = fileinfo[FILESIZE_HH]; filesize = (filesize << 8) + fileinfo[FILESIZE_MM]; filesize = (filesize << 8) + fileinfo[FILESIZE_LL]; displist_c_printf(disp_fsc, "% 7ld", filesize); } /* ¥¿¥¤¥à¥¹¥¿¥ó¥×¤ÎÆüÉÕÉôʬ¤Îɽ¼¨ */ if(showdate == ON){ dateword = fileinfo[DATE_HH] << 8; dateword += fileinfo[DATE_LL]; year = ((dateword & YEAR_MASK) >> YEAR_SHIFT) + 1980; mon = ((dateword & MON_MASK) >> MON_SHIFT); day = (dateword & DAY_MASK); displist_c_printf(disp_fdc, " %02d/%02d/%02d", (year % 100), mon, day); } /* ¥¿¥¤¥à¥¹¥¿¥ó¥×¤Î»þ¹ïÉôʬ¤Îɽ¼¨ */ if(showtime == ON){ timeword = fileinfo[TIME_HH] << 8; timeword += fileinfo[TIME_LL]; hour = ((timeword & HOUR_MASK) >> HOUR_SHIFT); min = ((timeword & MIN_MASK) >> MIN_SHIFT); sec = (timeword & SEC_MASK) * 2; displist_c_printf(disp_ftc, " %02d:%02d:%02d", hour, min, sec); } displist_c_printf(-1, "\n"); return 0; } int disp_dirinfo(int deleted, int ut_dir, int sec_num, unsigned char *fat_buffer[], unsigned char *data_buffer[], int level, int dir_indent, unsigned char parent_dir_name0) { int nfiles; int i; int subdir_sec_num; unsigned char fileinfo[32]; nfiles = 0; do{ if(data_buffer[sec_num - 2] != NULL){ /* return nfiles; */ for(i = 0; i < 4; i++){ memcpy(fileinfo, (data_buffer[sec_num - 2] + i * 32), 32); if(fileinfo[0] == 0x00){ return nfiles; } if((ut_dir == OFF) && (fileinfo[0] == '.')){ continue; } nfiles++; displist_c_printf(0, "%*s", level * dir_indent, ""); /* ^- ¤³¤¦¤¤¤¦¤³¤È¤¬¤Ç¤­¤ë¤Ê¤ó¤Æ¡ª ËÞ¯¸*/ disp_fileinfo(fileinfo, deleted, parent_dir_name0, fat_buffer, data_buffer); if(fileinfo[ATTR_OFFS] & DIR_ATTR){ nfiles--; if(fileinfo[0] != '.'){ subdir_sec_num = fileinfo[FAT_LL]; subdir_sec_num += (fileinfo[FAT_HH] << 8); nfiles += disp_dirinfo(deleted, ut_dir, subdir_sec_num, fat_buffer, data_buffer, level+1, dir_indent, parent_dir_name0); } } } } sec_num = get_fat(sec_num, fat_buffer); }while(sec_num != 0xff0); return nfiles; }