MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / Close

Method Close

src/Storage/FileStore.cpp:184–243  ·  view source on GitHub ↗

This may be called from an ISR, in which case we need to defer the close

Source from the content-addressed store, hash-verified

182
183// This may be called from an ISR, in which case we need to defer the close
184bool FileStore::Close() noexcept
185{
186 switch (usageMode)
187 {
188 case FileUseMode::free:
189 if (!inInterrupt())
190 {
191 REPORT_INTERNAL_ERROR;
192 }
193 return false;
194
195 case FileUseMode::readOnly:
196 case FileUseMode::readWrite:
197 {
198 const auto flags = IrqSave();
199 if (openCount > 1)
200 {
201 --openCount;
202 IrqRestore(flags);
203 return true;
204 }
205 else if (inInterrupt())
206 {
207 closeRequested = true;
208 IrqRestore(flags);
209 return true;
210 }
211 else
212 {
213 IrqRestore(flags);
214 return ForceClose();
215 }
216 }
217
218 case FileUseMode::invalidated:
219 default:
220 {
221 const auto flags = IrqSave();
222 if (openCount > 1)
223 {
224 --openCount;
225 IrqRestore(flags);
226 }
227 else
228 {
229#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE
230 FileWriteBuffer *wb = nullptr;
231 std::swap(wb, writeBuffer);
232 IrqRestore(flags);
233 if (wb != nullptr)
234 {
235 MassStorage::ReleaseWriteBuffer(wb);
236 }
237#endif
238 usageMode = FileUseMode::free;
239 }
240 return true;
241 }

Callers 15

AccelerometerTaskCodeFunction · 0.45
Accelerometers.cppFile · 0.45
ProcessReceivedDataMethod · 0.45
ImageMenuItem.cppFile · 0.45
ReloadMethod · 0.45
StopMethod · 0.45
LogMessageMethod · 0.45
InternalLogMessageMethod · 0.45
RepRap.cppFile · 0.45
UpdateFirmwareMethod · 0.45
CloseDataCollectionFileFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected