MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / contiguousRange

Method contiguousRange

Marlin/src/sd/SdBaseFile.cpp:122–141  ·  view source on GitHub ↗

* Check for contiguous file and return its raw block range. * * \param[out] bgnBlock the first block address for the file. * \param[out] endBlock the last block address for the file. * * \return true for success, false for failure. * Reasons for failure include file is not contiguous, file has zero length * or an I/O error occurred. */

Source from the content-addressed store, hash-verified

120 * or an I/O error occurred.
121 */
122bool SdBaseFile::contiguousRange(uint32_t * const bgnBlock, uint32_t * const endBlock) {
123 // error if no blocks
124 if (firstCluster_ == 0) return false;
125
126 for (uint32_t c = firstCluster_; ; c++) {
127 uint32_t next;
128 if (!vol_->fatGet(c, &next)) return false;
129
130 // check for contiguous
131 if (next != (c + 1)) {
132 // error if not end of chain
133 if (!vol_->isEOC(next)) return false;
134 *bgnBlock = vol_->clusterStartBlock(firstCluster_);
135 *endBlock = vol_->clusterStartBlock(c)
136 + vol_->blocksPerCluster_ - 1;
137 return true;
138 }
139 }
140 return false;
141}
142
143/**
144 * Create and open a new contiguous file of a specified size.

Callers

nothing calls this directly

Calls 3

fatGetMethod · 0.80
isEOCMethod · 0.80
clusterStartBlockMethod · 0.80

Tested by

no test coverage detected