Ewavr, you found readdir. Any comments?
ROM:FFDC1BC0 LDRB R1, [R0,#0xB] ; read attributes byteROM:FFDC1BC4 CMP R1, #0xF ; is long filename?ROM:FFDC1BC8 BEQ loc_FFDC1BF8 ROM:FFDC1BCC TST R1, #8 ; is volume label ?ROM:FFDC1BD0 BNE loc_FFDC1BF8 ROM:FFDC1BD4 LDRB R1, [R0] ROM:FFDC1BD8 CMP R1, #0xE5 ; is deleted file entry ?ROM:FFDC1BDC BEQ loc_FFDC1C08
upd: It seems that OpenFastDir() calls Open(directory_name, 0, 0x124), ReadFastDir reads entries from this file... If this is true, we don't need any xxxFastDir(), we can make own
typedef struct { char fname[8]; char fext[3]; char attr; // is there a numeric one-byte-datatype? char reserved[10]; short time; short date; short start_cluster; int fsize;} fat_de;typedef struct { char seqno; // numeric char fname_p1[10]; char attr; // numeric char reserved; char chksum; char fname_p2[12]; short start_cluster; // always 0 for lfn-entries char fname_p3[4];} fat_lfn;
if (cnt == 100) { char *de_char; // one directory entry fat_de *de; // one directory entry fat_lfn *lfn; // long filename entry char cur_de[50]; // text-output of current entry char lfn_part[255];// long filename int dh = open("A/CHDK", 0, 0444); de_char = malloc(32); de = (fat_de*) de_char; lfn = (fat_lfn*) de_char; if (dh > 0) { int lnr = 0; while (read(dh, de_char, 32) > 0) { // get next entry if (lnr > 15) { continue; } // can't display more if (de_char[0] == 0) { continue; } // empty entry if (de_char[0] == 0xe5 ){ continue; } // deleted entry if ((int)de->attr == 0x0f) { // lfn char tmp[12]; // new lfn, truncate string if ((int) lfn->seqno == 1) { lfn_part[0] = 0; } // add pieces of filename from lfn-entry to previous entry strncpy(tmp, lfn->fname_p1, 10); strcat(lfn_part, tmp); strncpy(tmp, lfn->fname_p2, 12); strcat(lfn_part, tmp); strncpy(tmp, lfn->fname_p3, 4); strcat(lfn_part, tmp); // this doesn't work (displays unusual characters) sprintf(cur_de, "%s :%x", lfn_part, de->attr); draw_txt_string(0, lnr++, cur_de, 0xff); } else { // regular filename sprintf(cur_de, "%s :%x", de->fname, de->attr); draw_txt_string(0, lnr++, cur_de, 0xff); } } } else { strcpy(cur_de, "dopen failed."); draw_txt_string(4, 4, cur_de, 0xff); } close(dh); free(de_char);}
the name is stored in unicode format. a double byte character system designed to handle all possible foreign and scientific characters. the orginal ascii characters are the same except they are two bytes in size, the second byte is a null; 00. check http://www.unicode.org for a more in depth explaination. there can be up to 13 unicode characters per 32 byte section. if however the long file name does not fill the slot exactly a unicode null (00,00) will be added to the end, followed by ff,ff's until the section is filled. note that entries do not have to have a lfn.
/* flags for attributes field */#define FATFS_ATTR_NORMAL 0x00 /* normal file */#define FATFS_ATTR_READONLY 0x01 /* file is readonly */#define FATFS_ATTR_HIDDEN 0x02 /* file is hidden */#define FATFS_ATTR_SYSTEM 0x04 /* file is a system file */#define FATFS_ATTR_VOLUME 0x08 /* entry is a volume label */#define FATFS_ATTR_DIRECTORY 0x10 /* entry is a directory name */#define FATFS_ATTR_ARCHIVE 0x20 /* file is new or modified */#define FATFS_ATTR_LFN 0x0f /* A long file name entry */#define FATFS_ATTR_ALL 0x3f /* all flags set */ /* constants for first byte of name[] */#define FATFS_SLOT_EMPTY 0x00#define FATFS_SLOT_E5 0x05 /* actual value is 0xe5 */#define FATFS_SLOT_DELETED 0xe5typedef unsigned char u_int8_t;typedef unsigned int u_int32_t;/* directory entry short name structure */typedef struct { u_int8_t name[8]; u_int8_t ext[3]; u_int8_t attrib; u_int8_t lowercase; u_int8_t ctimeten; /* create times */ u_int8_t ctime[2]; u_int8_t cdate[2]; u_int8_t adate[2]; /* access time */ u_int8_t highclust[2]; u_int8_t wtime[2]; /* last write time */ u_int8_t wdate[2]; u_int8_t startclust[2]; u_int8_t size[4];} fatfs_dentry; typedef struct { u_int8_t seq; u_int8_t part1[10]; u_int8_t attributes; u_int8_t reserved1; u_int8_t chksum; u_int8_t part2[12]; u_int8_t reserved2[2]; u_int8_t part3[4];} fatfs_dentry_lfn;
Started by neilp1 « 1 2 3 » General Discussion and Assistance
Started by badmoon Feature Requests
Started by bugbear Script Writing
Started by ano Feature Requests
Started by waterwingz « 1 2 ... 10 11 » General Discussion and Assistance