Skip to content

Commit 0491519

Browse files
LDong-Armkjbracey
andcommitted
Fix mbed::Dir type handling in fat_filesystem
Full credits to @kjbracey-arm for the fix. Co-authored-by: Kevin Bracey <[email protected]>
1 parent f227856 commit 0491519

File tree

1 file changed

+12
-12
lines changed
  • storage/filesystem/fat/tests/TESTS/fat/fat_filesystem

1 file changed

+12
-12
lines changed

storage/filesystem/fat/tests/TESTS/fat/fat_filesystem/main.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,28 +134,28 @@ void test_read_dir()
134134
err = dir.open(&fs, "test_read_dir");
135135
TEST_ASSERT_EQUAL(0, err);
136136

137-
struct dirent *de;
137+
struct dirent de;
138138
bool test_dir_found = false;
139139
bool test_file_found = true;
140140

141-
while ((de = readdir(&dir))) {
142-
printf("d_name: %.32s, d_type: %x\n", de->d_name, de->d_type);
141+
while (dir.read(&de) == 1) {
142+
printf("d_name: %.32s, d_type: %x\n", de.d_name, de.d_type);
143143

144-
if (strcmp(de->d_name, ".") == 0) {
144+
if (strcmp(de.d_name, ".") == 0) {
145145
test_dir_found = true;
146-
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
147-
} else if (strcmp(de->d_name, "..") == 0) {
146+
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
147+
} else if (strcmp(de.d_name, "..") == 0) {
148148
test_dir_found = true;
149-
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
150-
} else if (strcmp(de->d_name, "test_dir") == 0) {
149+
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
150+
} else if (strcmp(de.d_name, "test_dir") == 0) {
151151
test_dir_found = true;
152-
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
153-
} else if (strcmp(de->d_name, "test_file") == 0) {
152+
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
153+
} else if (strcmp(de.d_name, "test_file") == 0) {
154154
test_file_found = true;
155-
TEST_ASSERT_EQUAL(DT_REG, de->d_type);
155+
TEST_ASSERT_EQUAL(DT_REG, de.d_type);
156156
} else {
157157
char *buf = new char[NAME_MAX];
158-
snprintf(buf, NAME_MAX, "Unexpected file \"%s\"", de->d_name);
158+
snprintf(buf, NAME_MAX, "Unexpected file \"%s\"", de.d_name);
159159
TEST_ASSERT_MESSAGE(false, buf);
160160
}
161161
}

0 commit comments

Comments
 (0)