Ejemplo n.º 1
0
bool KOutgoingMessage::save()
{
	string_512 fullpath = this->buildMessageFullPath();
	if(fullpath.empty()) return true;

	KOutputFileStream fo;
	if(!fo.OpenForce(fullpath.c_str(), "w+"))
	{
		Log(LOG_ERROR, "error: open '%s'", fullpath.c_str());
		return false;
	}
	
	KInputFileStream fi;
	if(!fi.Open(m_messageFile.c_str(), "rb"))
	{
		Log(LOG_ERROR, "error: open '%s'", m_messageFile.c_str());
		return false;
	}

	char buf[1024]; int n;
	while(n = fi.ReadData(buf, sizeof(buf)), n > 0) fo.WriteData(buf, n);
	fi.Close(); fo.Close();

	if(!m_messageFile.empty() && m_isTmpFile)
		System::File::KFileUtil::deleteFile(m_messageFile.c_str());
	
	return saveMessageToDB(this);
}
Ejemplo n.º 2
0
void FS_LoadAvatar::execute()
{
	string_512 filepath = m_target->buildAvatarFilePath(m_target->m_avatar.c_str());
	KInputFileStream fi;
	if(!fi.Open(filepath.c_str(), "rb"))
	{
		m_result = GetLastError();
		Log(LOG_ERROR, "error: open '%s', %s", filepath.c_str(), strerror_r2(m_result).c_str());
		m_result = JgErrorCode::err_OpenFile;
		return;
	}

	int n; char buf[1024];
	while(n = fi.ReadData(buf, sizeof(buf)), n > 0)
		m_avatarData.WriteData(buf, n);

	return;
}