Example #1
0
QStringList FileHandler::toQStringList()
{
    emit logmsg(fileName+" ["+getFileStatusString()+"] "+QString::number(fileAge()));
    QStringList tmpStringContainer;

    if(
        (  (getFileStatus() == good) || (getFileStatus() == exists)    )
       &&
        (   fileObject.open(QIODevice::ReadOnly | QIODevice::Text)  )
      )
    {
        QTextStream tmpFileStream(&fileObject);
        QString tmpLine = tmpFileStream.readLine();

        while (!tmpLine.isNull())
        {
            tmpStringContainer.push_back(tmpLine);
            tmpLine = tmpFileStream.readLine();
        }
        emit logmsg("FH: parsed:" + QString::number(tmpStringContainer.size()) + " lines" );
        fileObject.close();
        emit logmsg(m_Downloader->getLogContent());
    }
    return tmpStringContainer;
}
Example #2
0
void NetworkManager::sendFileList()
{
	ByteBuffer buffer;

	// type(byte) 6
	// D or F, file (zero ended string), age (int)
	// D or F, file (zero ended string), age (int)
	// ....

	buffer.append((char)6);

	std::vector<std::string> files, directories;
	getDirectoryListingR(resourceDirectory_.c_str(), &files, &directories);

	for (std::size_t i = 0; i < files.size(); ++i)
	{
		buffer.append('F');
		buffer.append(files[i]);
		int age = fileAge(pathForFileEx(resourceDirectory_.c_str(), files[i].c_str()));
		buffer.append(age);

		std::map<std::string, std::vector<unsigned char> >::iterator iter = md5_.find(files[i]);
		if (iter == md5_.end())
		{
			calculateMD5(files[i].c_str());
			saveMD5();
			iter = md5_.find(files[i]);
		}
		buffer.append(&iter->second[0], 16);
	}

	for (std::size_t i = 0; i < directories.size(); ++i)
	{
		buffer.append('D');
		buffer.append(directories[i]);
	}

	serverSendData(buffer.data(), buffer.size());
}
Example #3
0
bool FileHandler::isOutdated()const
{
    return (fileAge()>daysToExpire)? true : false;
}