Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-08-21 19:22:56 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-08-21 19:22:56 +0300
commit65510a271617119f47395e28b8ba42740776e66e (patch)
tree7c9d9c50a299de719a23f90e607489abf4ea1557 /src/Storage
parentc651d94883ab123e569aa3e1b19464dade60b5e3 (diff)
Implemented redirection to file in echo command
Diffstat (limited to 'src/Storage')
-rw-r--r--src/Storage/FileData.h14
-rw-r--r--src/Storage/FileStore.cpp2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/Storage/FileData.h b/src/Storage/FileData.h
index 63a38e01..a10c1c0b 100644
--- a/src/Storage/FileData.h
+++ b/src/Storage/FileData.h
@@ -23,6 +23,8 @@ public:
FileData() noexcept : f(nullptr) {}
+ ~FileData() { (void)Close(); }
+
FileData(const FileData& other) noexcept
{
f = other.f;
@@ -32,6 +34,15 @@ public:
}
}
+ FileData(FileData&& other) noexcept
+ {
+ f = other.f;
+ other.f = nullptr;
+ }
+
+ // Make sure we don't assign these objects
+ FileData& operator=(const FileData&) = delete;
+
// Set this to refer to a newly-opened file
void Set(FileStore* pfile) noexcept
{
@@ -125,9 +136,6 @@ private:
{
f = nullptr;
}
-
- // Private assignment operator to prevent us assigning these objects
- FileData& operator=(const FileData&) noexcept;
};
#endif
diff --git a/src/Storage/FileStore.cpp b/src/Storage/FileStore.cpp
index 617c26ff..a37eec73 100644
--- a/src/Storage/FileStore.cpp
+++ b/src/Storage/FileStore.cpp
@@ -128,7 +128,7 @@ bool FileStore::Open(const char* filePath, OpenMode mode, uint32_t preAllocSize)
{
const FRESULT openReturn = f_open(&file, filePath,
(mode == OpenMode::write || mode == OpenMode::writeWithCrc) ? FA_CREATE_ALWAYS | FA_WRITE
- : (mode == OpenMode::append) ? FA_READ | FA_WRITE | FA_OPEN_ALWAYS
+ : (mode == OpenMode::append) ? FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_OPEN_APPEND
: FA_OPEN_EXISTING | FA_READ);
if (openReturn == FR_OK)
{