diff --git a/src/fs/CFile.cpp b/src/fs/CFile.cpp index b92d8ca..729f5fe 100644 --- a/src/fs/CFile.cpp +++ b/src/fs/CFile.cpp @@ -107,7 +107,7 @@ int32_t CFile::read(uint8_t *ptr, size_t size) { return -1; } -int32_t CFile::write(const uint8_t *ptr, size_t size) { +int64_t CFile::write(const uint8_t *ptr, size_t size) { if (iFd >= 0) { size_t done = 0; while (done < size) { diff --git a/src/fs/CFile.hpp b/src/fs/CFile.hpp index 34219a1..2a9cce3 100644 --- a/src/fs/CFile.hpp +++ b/src/fs/CFile.hpp @@ -42,7 +42,7 @@ public: int32_t read(uint8_t *ptr, size_t size); - int32_t write(const uint8_t *ptr, size_t size); + int64_t write(const uint8_t *ptr, size_t size); int32_t fwrite(const char *format, ...); diff --git a/src/fs/FSUtils.cpp b/src/fs/FSUtils.cpp index 283629d..b7037b5 100644 --- a/src/fs/FSUtils.cpp +++ b/src/fs/FSUtils.cpp @@ -132,10 +132,14 @@ int32_t FSUtils::CreateSubfolder(const char *fullpath) { BOOL FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size) { CFile file(path, CFile::WriteOnly); if (!file.isOpen()) { - DEBUG_FUNCTION_LINE("Failed to open %s\n", path); + DEBUG_FUNCTION_LINE_ERR("Failed to open %s\n", path); + return false; + } + if (file.write((const uint8_t *) buffer, size) != size) { + DEBUG_FUNCTION_LINE_ERR("Failed to write file %s\n", path); + file.close(); return false; } - file.write((const uint8_t *) buffer, size); file.close(); return true; }