Skip to content

Commit

Permalink
Fix name clashes in FAT filesystem (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioCesarMatias authored Jun 21, 2021
1 parent febd629 commit dd91486
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/io/asyncfatfs/asyncfatfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2255,8 +2255,18 @@ static void afatfs_createFileContinue(afatfsFile_t *file) {
opState->phase = AFATFS_CREATEFILE_PHASE_FAILURE;
goto doMore;
}
} else if (entry->attrib & FAT_FILE_ATTRIBUTE_VOLUME_ID) {
break;
} else if (strncmp(entry->filename, (char*) opState->filename, FAT_FILENAME_LENGTH) == 0) {
// We found a file with this name!
// We found a file or directory with this name!

// Do not open file as dir or dir as file
if (((entry->attrib ^ file->attrib) & FAT_FILE_ATTRIBUTE_DIRECTORY) != 0) {
afatfs_findLast(&afatfs.currentDirectory);
opState->phase = AFATFS_CREATEFILE_PHASE_FAILURE;
goto doMore;
}

afatfs_fileLoadDirectoryEntry(file, entry);
afatfs_findLast(&afatfs.currentDirectory);
opState->phase = AFATFS_CREATEFILE_PHASE_SUCCESS;
Expand Down

0 comments on commit dd91486

Please sign in to comment.