check if file is opened in destructor

This commit is contained in:
Amar Mahmutbegovic
2024-11-03 16:00:05 +01:00
parent 60b08160ba
commit 49b062908b

View File

@@ -16,6 +16,8 @@ namespace fs{
struct lfs { struct lfs {
lfs() = delete;
static inline lfs_t fs_lfs; static inline lfs_t fs_lfs;
static void init() { static void init() {
@@ -33,9 +35,11 @@ public:
} }
} }
~file() { ~file() {
if(is_open()) {
printf("Closing file in destructor.\r\n"); printf("Closing file in destructor.\r\n");
lfs_file_close(&lfs::fs_lfs, &file_); lfs_file_close(&lfs::fs_lfs, &file_);
} }
}
[[nodiscard]] bool is_open() const { [[nodiscard]] bool is_open() const {
return is_open_; return is_open_;