+ return true;
+}
+ /*}}}*/
+// TagFile::Fill - Top up the buffer /*{{{*/
+// ---------------------------------------------------------------------
+/* This takes the bit at the end of the buffer and puts it at the start
+ then fills the rest from the file */
+bool pkgTagFile::Fill()
+{
+ unsigned long long EndSize = d->End - d->Start;
+ unsigned long long Actual = 0;
+
+ memmove(d->Buffer,d->Start,EndSize);
+ d->Start = d->Buffer;
+ d->End = d->Buffer + EndSize;
+
+ if (d->Done == false)
+ {
+ // See if only a bit of the file is left
+ if (d->Fd.Read(d->End, d->Size - (d->End - d->Buffer),&Actual) == false)
+ return false;
+ if (Actual != d->Size - (d->End - d->Buffer))
+ d->Done = true;
+ d->End += Actual;
+ }
+
+ if (d->Done == true)
+ {
+ if (EndSize <= 3 && Actual == 0)
+ return false;
+ if (d->Size - (d->End - d->Buffer) < 4)
+ return true;
+
+ // Append a double new line if one does not exist
+ unsigned int LineCount = 0;
+ for (const char *E = d->End - 1; E - d->End < 6 && (*E == '\n' || *E == '\r'); E--)
+ if (*E == '\n')
+ LineCount++;
+ for (; LineCount < 2; LineCount++)
+ *d->End++ = '\n';
+
+ return true;
+ }
+