Пример #1
0
void InitLogic::HandleTOU(GetHTTPDocumentOp *theOp)
{
	time_t oldSysTime, oldGameTime;
	LobbyMisc::GetTOUTimes(oldSysTime, oldGameTime);

	bool needSetTimes = false;


	// Copy SysTOU if newer
	if(theOp->GetDocumentStatus(HTTPDocOwner_Sys)==WS_Success && theOp->GetModifiedTime(HTTPDocOwner_Sys)>oldSysTime)
	{
		// write the sys document
		FileWriter aWriter;
		try
		{
			if(aWriter.Open(LobbyMisc::GetSysTOUPath().c_str(),true))
			{
				ByteBufferPtr aDoc = theOp->GetDocument(HTTPDocOwner_Sys);
				if(aDoc->length()>1)
					aWriter.WriteBytes(aDoc->data(), aDoc->length()-1); // don't write the null character at the end
			}
			needSetTimes = true;
		}
		catch(FileWriterException&)
		{
		}
	}

	// Copy GameTOU if newer
	if(theOp->GetDocumentStatus(HTTPDocOwner_Game)==WS_Success && theOp->GetModifiedTime(HTTPDocOwner_Game)>oldGameTime)
	{
		// write the game document
		FileWriter aWriter;
		try
		{
			if(aWriter.Open(LobbyMisc::GetGameTOUPath().c_str(),true))
			{
				ByteBufferPtr aDoc = theOp->GetDocument(HTTPDocOwner_Game);
				if(aDoc->length()>1)
					aWriter.WriteBytes(aDoc->data(), aDoc->length()-1); // don't write the null character at the end
			}
			needSetTimes = true;
		}
		catch(FileWriterException&)
		{
		}
	}

	if(needSetTimes)
		SetTOUTimes();
}
Пример #2
0
bool WIMDecoder::EncodeToFile(RawImagePtr theImage, const char *theFilePath)
{
	FileWriter aWriter;
	if(!aWriter.Open(theFilePath,true))
		return false;

	ByteBufferPtr aBuf = EncodeToBuffer(theImage);
	if(aBuf.get()==NULL)
		return false;

	try
	{
		aWriter.WriteBytes(aBuf->data(),aBuf->length());
	}
	catch(FileWriterException&)
	{
	}

	return true;
}
void SPAuthCheckPrv::WriteCheckFile()
{
	
	if(mGameSecondsBeforeNextCheck==1) // Remove file to force check next time
	{
		WONFile aFile(gSPAuthCheck_FileName);
		aFile.Remove();
		return;
	}

	// Write new file
	try
	{
		FileWriter aWriter;
		if(!aWriter.Open(gSPAuthCheck_FileName))
			return;

		WONFile aFile(gSPAuthCheck_FileName);

		WriteBuffer anEncrypt;
		anEncrypt.AppendString("magic");
		anEncrypt.AppendLong(aFile.GetCreateTime()); // file creation time
		anEncrypt.AppendLong(mGameSecondsBeforeNextCheck);

		ByteBufferPtr aBuf = mEncryptKey.Encrypt(anEncrypt.data(),anEncrypt.length());
		if(aBuf.get()==NULL)
			return;

		aWriter.WriteShort(aBuf->length());
		aWriter.WriteBytes(aBuf->data(),aBuf->length());
	}
	catch(FileWriterException&)
	{
	}


}