Skip to content

FATFileSystem::stat() enabled for all compilers #11193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/storage/TESTS/filesystem/fat_filesystem/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ void test_read_write()
err = file.close();
TEST_ASSERT_EQUAL(0, err);

struct stat st;
err = fs.stat("test_read_write.dat", &st);
TEST_ASSERT_EQUAL(TEST_SIZE, st.st_size);

err = file.open(&fs, "test_read_write.dat", O_RDONLY);
TEST_ASSERT_EQUAL(0, err);
size = file.read(buffer, TEST_SIZE);
Expand Down
3 changes: 0 additions & 3 deletions features/storage/filesystem/fat/FATFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,12 @@ int FATFileSystem::stat(const char *path, struct stat *st)
return fat_error_remap(res);
}

/* ARMCC doesnt support stat(), and these symbols are not defined by the toolchain. */
#ifdef TOOLCHAIN_GCC
st->st_size = f.fsize;
st->st_mode = 0;
st->st_mode |= (f.fattrib & AM_DIR) ? S_IFDIR : S_IFREG;
st->st_mode |= (f.fattrib & AM_RDO) ?
(S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) :
(S_IRWXU | S_IRWXG | S_IRWXO);
#endif /* TOOLCHAIN_GCC */
unlock();

return 0;
Expand Down