From a7307e0c0e0563c2de9cb0cd80e59795f151a208 Mon Sep 17 00:00:00 2001 From: tantricity Date: Tue, 21 Jun 2011 03:49:56 +0000 Subject: [PATCH] case sensitive patch (Extrems) --- source/directory.c | 14 ++++++++++---- source/directory.h | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/source/directory.c b/source/directory.c index 55de3bb..4ec6fce 100644 --- a/source/directory.c +++ b/source/directory.c @@ -204,8 +204,10 @@ static int _FAT_directory_mbsncasecmp (const char* s1, const char* s2, size_t le static bool _FAT_directory_entryGetAlias (const u8* entryData, char* destName) { - int i=0; - int j=0; + char c; + bool caseInfo; + int i = 0; + int j = 0; destName[0] = '\0'; if (entryData[0] != DIR_ENTRY_FREE) { @@ -219,14 +221,18 @@ static bool _FAT_directory_entryGetAlias (const u8* entryData, char* destName) { } } else { // Copy the filename from the dirEntry to the string + caseInfo = entryData[DIR_ENTRY_caseInfo] & CASE_LOWER_BASE; for (i = 0; (i < 8) && (entryData[DIR_ENTRY_name + i] != ' '); i++) { - destName[i] = entryData[DIR_ENTRY_name + i]; + c = entryData[DIR_ENTRY_name + i]; + destName[i] = (caseInfo ? tolower(c) : c); } // Copy the extension from the dirEntry to the string if (entryData[DIR_ENTRY_extension] != ' ') { destName[i++] = '.'; + caseInfo = entryData[DIR_ENTRY_caseInfo] & CASE_LOWER_EXT; for ( j = 0; (j < 3) && (entryData[DIR_ENTRY_extension + j] != ' '); j++) { - destName[i++] = entryData[DIR_ENTRY_extension + j]; + c = entryData[DIR_ENTRY_extension + j]; + destName[i++] = (caseInfo ? tolower(c) : c); } } destName[i] = '\0'; diff --git a/source/directory.h b/source/directory.h index 9342921..ac66c78 100644 --- a/source/directory.h +++ b/source/directory.h @@ -57,6 +57,9 @@ #define ATTRIB_HID 0x02 // Hidden #define ATTRIB_RO 0x01 // Read only +#define CASE_LOWER_EXT 0x10 // WinNT lowercase extension +#define CASE_LOWER_BASE 0x08 // WinNT lowercase basename + typedef enum {FT_DIRECTORY, FT_FILE} FILE_TYPE; typedef struct { @@ -77,7 +80,7 @@ enum DIR_ENTRY_offset { DIR_ENTRY_name = 0x00, DIR_ENTRY_extension = 0x08, DIR_ENTRY_attributes = 0x0B, - DIR_ENTRY_reserved = 0x0C, + DIR_ENTRY_caseInfo = 0x0C, DIR_ENTRY_cTime_ms = 0x0D, DIR_ENTRY_cTime = 0x0E, DIR_ENTRY_cDate = 0x10,