Handle WinNT-style filename case flags (where it uses a shortname only
but with flags to indicate the filename case.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
} else {
/* Use the shortname */
int i;
+ uint8_t c;
char *p = filename;
for (i = 0; i < 8; i++) {
- if (de->name[i] == ' ')
+ c = de->name[i];
+ if (c == ' ')
break;
- *p++ = de->name[i];
+ if (de->lcase & LCASE_BASE)
+ c = codepage.lower[c];
+ *p++ = c;
}
- *p++ = '.';
- if (de->name[8] == ' ') {
- *--p = '\0';
- } else {
+ if (de->name[8] != ' ') {
+ *p++ = '.';
for (i = 8; i < 11; i++) {
- if (de->name[i] == ' ')
+ c = de->name[i];
+ if (c == ' ')
break;
- *p++ = de->name[i];
+ if (de->lcase & LCASE_EXT)
+ c = codepage.lower[c];
+ *p++ = c;
}
- *p = '\0';
}
+ *p = '\0';
goto got;
}
struct fat_dir_entry {
char name[11];
uint8_t attr;
- uint8_t nt_reserved;
+ uint8_t lcase;
uint8_t c_time_tenth;
uint16_t c_time;
uint16_t c_date;
uint32_t file_size;
} __attribute__ ((packed));
-
+#define LCASE_BASE 8 /* basename is lower case */
+#define LCASE_EXT 16 /* extension is lower case */
struct fat_long_name_entry {
uint8_t id;