BOOL FAT_LONG_Directory::IsName( LPCWSTR name, UINT32 nameLen ) { int j; WCHAR c; for(j = 0; j < LDIR_Name1__size; j+=2) { // LDIR_Name1 is in BYTEs because it's not UINT16 aligned c = ((UINT16)LDIR_Name1[j]) | ((UINT16)LDIR_Name1[j+1]) << 8; if(c == 0 && nameLen == 0) { return TRUE; } else if(nameLen == 0 || MF_towupper( c ) != MF_towupper( *name )) { return FALSE; } name++; nameLen--; } for(j = 0; j < LDIR_Name2__size; j+=2) { c = ((UINT16)LDIR_Name2[j]) | ((UINT16)LDIR_Name2[j+1]) << 8; if(c == 0 && nameLen == 0) { return TRUE; } else if(nameLen == 0 || MF_towupper( c ) != MF_towupper( *name )) { return FALSE; } name++; nameLen--; } for(j = 0; j < LDIR_Name3__size; j+=2) { c = ((UINT16)LDIR_Name3[j]) | ((UINT16)LDIR_Name3[j+1]) << 8; if(c == 0 && nameLen == 0) { return TRUE; } else if(nameLen == 0 || MF_towupper( c ) != MF_towupper( *name )) { return FALSE; } name++; nameLen--; } return TRUE; }
BOOL FAT_Directory::IsName( LPCWSTR name, UINT32 nameLen ) { char c; int j; // Compare the base name for(j = 0; j < SHORTNAME_SIZE && nameLen > 0; j++) { c = (char)(*name); name++; nameLen--; // stop if we see the "." if(c == '.') break; if(j == 0 && c == 0xE5) c = 0x05; if(MF_towupper(DIR_Name[j]) != MF_towupper(c)) return FALSE; } // the rest of the base name has to be blanks for(; j < 8; j++) { if(DIR_Name[j] != WHITESPACE_CHAR) return FALSE; } // Only compare the extension if there is one if(nameLen > 0) { // skip the '.' if we haven't already if(*name == '.') { name++; nameLen--; } // Compare the extension for(; j < SHORTNAME_FULL_SIZE && nameLen > 0; j++) { c = (char)(*name); name++; nameLen--; if(MF_towupper(DIR_Name[j]) != MF_towupper(c)) return FALSE; } } // the rest of the extension has to be blanks for(; j < 11; j++) { if(DIR_Name[j] != WHITESPACE_CHAR) return FALSE; } return TRUE; }