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

Method OpenFile

src/SBC/SbcInterface.cpp:1648–1693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1646}
1647
1648FileHandle SbcInterface::OpenFile(const char *filename, OpenMode mode, FilePosition& fileLength, uint32_t preAllocSize) noexcept
1649{
1650 // Don't do anything if the SBC is not connected
1651 if (!IsConnected())
1652 {
1653 return false;
1654 }
1655
1656 // Set up the request content
1657 MutexLocker locker(fileMutex);
1658
1659 filePath = filename;
1660 filePreAllocSize = preAllocSize;
1661 FileOperation op;
1662 switch (mode)
1663 {
1664 case OpenMode::read:
1665 op = FileOperation::openRead;
1666 break;
1667
1668 case OpenMode::write:
1669 case OpenMode::writeWithCrc:
1670 op = FileOperation::openWrite;
1671 break;
1672
1673 case OpenMode::append:
1674 op = FileOperation::openAppend;
1675 break;
1676
1677 default:
1678 filePath = nullptr;
1679 REPORT_INTERNAL_ERROR;
1680 return noFileHandle;
1681 }
1682
1683 if (!DoFileOperation(op))
1684 {
1685 fileLength = 0;
1686 reprap.GetPlatform().MessageF(ErrorMessage, "Timeout while trying to open file %s\n", filename);
1687 return noFileHandle;
1688 }
1689
1690 // Update the file length and return the handle
1691 fileLength = fileOffset;
1692 return fileHandle;
1693}
1694
1695int SbcInterface::ReadFile(FileHandle handle, char *buffer, size_t bufferLength) noexcept
1696{

Callers 15

ProcessLineMethod · 0.45
SendFileMethod · 0.45
StartUploadMethod · 0.45
SendUpdateFileMethod · 0.45
QueueFileToPrintMethod · 0.45
THROWSFunction · 0.45
StartHashMethod · 0.45
RunStateMachineMethod · 0.45
OpenFileToWriteMethod · 0.45
ImageMenuItem.cppFile · 0.45
ReloadMethod · 0.45
RepRap.cppFile · 0.45

Calls 2

IsConnectedFunction · 0.85
MessageFMethod · 0.45

Tested by

no test coverage detected