add FileIO operator = to prevent memory leak
This commit is contained in:
1 parent
2fe1630f5d
commit
c3b2f29288
2 files changed
+12
-1
No files matched your search
@@ -58,6 +58,16 @@ File::File (char const *filename, uint8_t mode, FileSystemClass &fs)
|
||||
open(filename, mode);
|
||||
}
|
||||
|
||||
File& File::operator = (const File &rhs)
|
||||
{
|
||||
// close if currently opened
|
||||
if ( _hdl ) close();
|
||||
|
||||
memcpy(this, &rhs, sizeof(File));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
File::~File ()
|
||||
{
|
||||
|
||||
@@ -139,7 +149,7 @@ void File::close (void)
|
||||
_name = NULL;
|
||||
}
|
||||
|
||||
File::operator bool ()
|
||||
File::operator bool (void)
|
||||
{
|
||||
return _hdl != NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user