private bool appendToStrip(int strip, byte[] buffer, int offset, int count)
{
const string module = "appendToStrip";
if (m_dir.td_stripoffset[strip] == 0 || m_curoff == 0)
{
Debug.Assert(m_dir.td_nstrips > 0);
if (m_dir.td_stripbytecount[strip] != 0 &&
m_dir.td_stripoffset[strip] != 0 &&
m_dir.td_stripbytecount[strip] >= count)
{
// There is already tile data on disk, and the new tile
// data we have to will fit in the same space. The only
// aspect of this that is risky is that there could be
// more data to append to this strip before we are done
// depending on how we are getting called.
if (!seekOK(m_dir.td_stripoffset[strip]))
{
ErrorExt(this, m_clientdata, module, "Seek error at scanline {0}", m_row);
return false;
}
}
else
{
// Seek to end of file, and set that as our location
// to write this strip.
m_dir.td_stripoffset[strip] = (uint)seekFile(0, SeekOrigin.End);
}
m_curoff = m_dir.td_stripoffset[strip];
// We are starting a fresh strip/tile, so set the size to zero.
m_dir.td_stripbytecount[strip] = 0;
}
if (!writeOK(buffer, offset, count))
{
ErrorExt(this, m_clientdata, module, "Write error at scanline {0}", m_row);
return false;
}
m_curoff += (uint)count;
m_dir.td_stripbytecount[strip] += (uint)count;
return true;
}