** Function name: checkExt ** Description: check file extension ***************************************************************************************/
| 489 | ** Description: check file extension |
| 490 | ***************************************************************************************/ |
| 491 | bool checkExt(String ext, String pattern) { |
| 492 | ext.toUpperCase(); |
| 493 | pattern.toUpperCase(); |
| 494 | if (ext == pattern) return true; |
| 495 | |
| 496 | // If the pattern is a list of extensions (e.g., "TXT|JPG|PNG"), split and check |
| 497 | int start = 0; |
| 498 | int end = pattern.indexOf('|'); |
| 499 | while (end != -1) { |
| 500 | String currentExt = pattern.substring(start, end); |
| 501 | if (ext == currentExt) { return true; } |
| 502 | start = end + 1; |
| 503 | end = pattern.indexOf('|', start); |
| 504 | } |
| 505 | |
| 506 | // Check the last extension in the list |
| 507 | String lastExt = pattern.substring(start); |
| 508 | return ext == lastExt; |
| 509 | } |
| 510 | |
| 511 | /*************************************************************************************** |
| 512 | ** Function name: readFs |