Skip to content

Commit 991ea11

Browse files
[fatdrvce] fix directory listing
1 parent 06c34a0 commit 991ea11

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

examples/library_examples/fatdrvce/fat_dir_tree/src/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,21 @@ fat_error_t scan_fat_files(char* path)
6969
faterr = fat_OpenDir(&fat, path, &dir);
7070
if (faterr != FAT_SUCCESS)
7171
{
72+
printf("error code %d\n", faterr);
7273
return faterr;
7374
}
7475

7576
for (;;)
7677
{
7778
faterr = fat_ReadDir(&dir, &entry);
78-
if (faterr != FAT_SUCCESS || entry.name[0] == 0)
79+
if (faterr != FAT_SUCCESS)
80+
{
81+
printf("error code %d", faterr);
82+
break;
83+
}
84+
85+
/* end of entries */
86+
if (entry.name[0] == 0)
7987
{
8088
break;
8189
}

src/fatdrvce/fatdrvce.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fat_ReadDir:
452452
ld bc,sizeof fatDirEntry
453453
xor a,a
454454
call ti.MemSet
455-
or a,a
455+
xor a,a
456456
sbc hl,hl ; success, zeroed entry at end
457457
pop ix
458458
ret

src/fatdrvce/fatdrvce.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ fat_error_t fat_Open(fat_t *fat,
140140

141141
/**
142142
* Closes the FAT filesystem. This is not required to be called, however
143-
* it will clear the filesystem dirty bit so other OSes don't see the filesystem
144-
* with potential errors. You cannot use the FAT structure after this call,
145-
* and should call fat_Open() if you need to modify the filesystem again.
143+
* it will clear the filesystem dirty bit so other OSes don't see the
144+
* filesystem with potential errors. You cannot use the FAT structure after
145+
* this call, and should call fat_Open() if you need to modify the filesystem
146+
* again.
146147
* @param[in] fat Initialized FAT structure type.
147148
* @return FAT_SUCCESS on success, otherwise error.
148149
*/
@@ -158,11 +159,11 @@ fat_error_t fat_Close(fat_t *fat);
158159
fat_error_t fat_OpenDir(fat_t *fat, const char *path, fat_dir_t *dir);
159160

160161
/**
161-
* Gets the next directory entry. If `entry.name[0] = 0`, then there are no more
162-
* entries to fetch.
162+
* Gets the next directory entry. If `entry.name[0]` is `0`, then there
163+
* are no more entries to fetch.
163164
* @param[in] dir Initialized directory handle from fat_OpenDir().
164165
* @param[out] entry Pointer to store entry information.
165-
* @return Number of entries found.
166+
* @return FAT_SUCCESS on success, otherwise error.
166167
*/
167168
fat_error_t fat_ReadDir(fat_dir_t *dir, fat_dir_entry_t *entry);
168169

0 commit comments

Comments
 (0)