Beispiel #1
0
bool LafsFlat::addFile(const FileEntry& file)
{
	WORD wEntryBuffer = 0x0000; //First bit is zero for a file

	int iTrailingFileSize = (static_cast<int>((file.getSize() / sizeof(WORD)) % 512 ) - 256) / 2;

	//Decrease one in magnitude as per spec
	iTrailingFileSize += (iTrailingFileSize >= 0 ? -1 : 1);
	
	WORD wEncodedTrailingSize = static_cast<WORD>(std::abs(iTrailingFileSize));

	if(iTrailingFileSize < 0)
		wEncodedTrailingSize |= 0x80; //Set sign bit

	wEntryBuffer |= wEncodedTrailingSize << 7;

	if(m_lafsEntries.size() >= LAFS_ENTRIES_PER_FLAT)
		return false;

	m_lafsEntries.push_back(LafsEntry(wEntryBuffer, file));

	return true;
}
Beispiel #2
0
static json::Object createFile(const FileEntry &FE) {
  return json::Object{{"fileLocation", createFileLocation(FE)},
                      {"roles", json::Array{"resultFile"}},
                      {"length", FE.getSize()},
                      {"mimeType", "text/plain"}};
}