Commit 37461f21 authored by Jack Andersen's avatar Jack Andersen

Add public waitForCompletion method

parent 0c012a37
......@@ -429,6 +429,11 @@ public:
*/
ECardResult getError() const;
/**
* @brief Block caller until any asynchronous I/O operations have completed
*/
void waitForCompletion() const;
operator bool() const { return getError() == ECardResult::READY; }
};
}
......
......@@ -862,8 +862,11 @@ void Card::format(ECardSlot id, ECardSize size, EEncoding encoding)
if (m_fileHandle)
{
uint32_t blockCount = (uint32_t(size) * MbitToBlocks) - 5;
m_tmpCh = m_ch;
m_tmpCh._swapEndian();
m_fileHandle.resizeQueue(5 + blockCount);
m_fileHandle.asyncWrite(0, &m_tmpCh, BlockSize, 0);
m_tmpDirs[0] = m_dirs[0];
m_tmpDirs[0].swapEndian();
......@@ -882,7 +885,6 @@ void Card::format(ECardSlot id, ECardSize size, EEncoding encoding)
DummyBlock.reset(new uint8_t[BlockSize]);
memset(DummyBlock.get(), 0xFF, BlockSize);
}
uint32_t blockCount = (uint32_t(size) * MbitToBlocks) - 5;
for (uint32_t i=0 ; i<blockCount ; ++i)
m_fileHandle.asyncWrite(i + 5, DummyBlock.get(), BlockSize, BlockSize * (i + 5));
m_dirty = false;
......@@ -988,4 +990,11 @@ ECardResult Card::getError() const
return ECardResult::READY;
}
void Card::waitForCompletion() const
{
if (!m_fileHandle)
return;
m_fileHandle.waitForCompletion();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment