Skip to content

Commit 74f6184

Browse files
committed
Automatically close files when the lifetime of the File object expires (the instance goes out of scope)
1 parent 0d31b45 commit 74f6184

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Arduino_SPIFFS_File.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Arduino_SPIFFS_File::Arduino_SPIFFS_File(spiffs * fs, spiffs_file const fh)
3333

3434
}
3535

36+
Arduino_SPIFFS_File::~Arduino_SPIFFS_File()
37+
{
38+
close();
39+
}
40+
3641
/**************************************************************************************
3742
* PUBLIC MEMBER FUNCTIONS
3843
**************************************************************************************/

src/Arduino_SPIFFS_File.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class Arduino_SPIFFS_File
4747

4848
public:
4949

50+
~Arduino_SPIFFS_File();
51+
52+
5053
String name ();
5154
inline int read (void * buf, int len) { return SPIFFS_read(_fs, _fh, buf, len); }
5255
inline int write (void * buf, int len) { return SPIFFS_write(_fs, _fh, buf, len); }

0 commit comments

Comments
 (0)