Skip to content

Commit

Permalink
Merge pull request #237 from Lamnxzp/fix
Browse files Browse the repository at this point in the history
Fixed: BIN files from being displayed even if they are not included in the allowed extensions.
  • Loading branch information
bmorcelli authored Sep 2, 2024
2 parents 1156d17 + ba8d993 commit ec83edc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/core/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ void clearFileList(String list[][3]) {
}
}
bool checkExt(String ext, String pattern) {
ext.toUpperCase();
pattern.toUpperCase();
if (ext == pattern) return true;

char charArray[pattern.length() + 1];
Expand All @@ -473,7 +475,6 @@ bool checkExt(String ext, String pattern) {
** Description: sort files for name
***************************************************************************************/
void readFs(FS fs, String folder, String result[][3], String allowed_ext) {

int allFilesCount = 0;
clearFileList(result);

Expand All @@ -488,14 +489,7 @@ void readFs(FS fs, String folder, String result[][3], String allowed_ext) {
String fileName = file2.name();
if (!file2.isDirectory()) {
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
ext.toUpperCase();
if (ext.equals("BIN")) {
result[allFilesCount][0] = fileName.substring(fileName.lastIndexOf("/") + 1);
result[allFilesCount][1] = file2.path();
result[allFilesCount][2] = "file";
allFilesCount++;
}
else if(allowed_ext=="*" || checkExt(ext, allowed_ext)) {
if (allowed_ext=="*" || checkExt(ext, allowed_ext)) {
result[allFilesCount][0] = fileName.substring(fileName.lastIndexOf("/") + 1);
result[allFilesCount][1] = file2.path();
result[allFilesCount][2] = "file";
Expand Down

0 comments on commit ec83edc

Please sign in to comment.