Beispiel #1
0
wxString GOrgueArchiveIndex::GenerateIndexFilename()
{
	GOrgueHash hash;
	hash.Update(m_Path);

	return m_Settings.UserCachePath()  + wxFileName::GetPathSeparator() + 
		hash.getStringHash() + wxT(".idx");
}
Beispiel #2
0
GOrgueHashType GOrgueArchiveIndex::GenerateHash()
{
	GOrgueHash hash;
	hash.Update(sizeof(wxString));
	hash.Update(sizeof(GOArchiveEntry));
	hash.Update(sizeof(size_t));

	wxFileName path_name(m_Path);
	uint64_t size = path_name.GetSize().GetValue();
	uint64_t time = path_name.GetModificationTime().GetTicks();
	hash.Update(time);
	hash.Update(size);

	return hash.getHash();
}
void GOrgueSoundingPipe::UpdateHash(GOrgueHash& hash)
{
	hash.Update(m_Filename);
	hash.Update(m_PipeConfig.GetEffectiveBitsPerSample());
	hash.Update(m_PipeConfig.GetEffectiveCompress());
	hash.Update(m_PipeConfig.GetEffectiveChannels());
	hash.Update(m_PipeConfig.GetEffectiveLoopLoad());
	hash.Update(m_PipeConfig.GetEffectiveAttackLoad());
	hash.Update(m_PipeConfig.GetEffectiveReleaseLoad());
	hash.Update(m_SampleMidiKeyNumber);
	hash.Update(m_LoopCrossfadeLength);
	hash.Update(m_ReleaseCrossfadeLength);

	hash.Update(m_AttackInfo.size());
	for(unsigned i = 0; i < m_AttackInfo.size(); i++)
	{
		m_AttackInfo[i].filename.Hash(hash);
		hash.Update(m_AttackInfo[i].sample_group);
		hash.Update(m_AttackInfo[i].max_playback_time);
		hash.Update(m_AttackInfo[i].load_release);
		hash.Update(m_AttackInfo[i].percussive);
		hash.Update(m_AttackInfo[i].cue_point);
		hash.Update(m_AttackInfo[i].loops.size());
		hash.Update(m_AttackInfo[i].attack_start);
		hash.Update(m_AttackInfo[i].release_end);
		for(unsigned j = 0; j < m_AttackInfo[i].loops.size(); j++)
		{
			hash.Update(m_AttackInfo[i].loops[j].loop_start);
			hash.Update(m_AttackInfo[i].loops[j].loop_end);
		}
	}

	hash.Update(m_ReleaseInfo.size());
	for(unsigned i = 0; i < m_ReleaseInfo.size(); i++)
	{
		m_ReleaseInfo[i].filename.Hash(hash);
		hash.Update(m_ReleaseInfo[i].sample_group);
		hash.Update(m_ReleaseInfo[i].max_playback_time);
		hash.Update(m_ReleaseInfo[i].cue_point);
		hash.Update(m_ReleaseInfo[i].release_end);
		}
}
bool GOrgueConfigFileReader::Read(GOrgueFile* file)
{
	m_Entries.clear();
	
	if (!file->Open())
	{
		wxLogError(_("Failed to open file '%s'"), file->GetName().c_str());
		return false;
	}
	GOrgueBuffer<uint8_t> data;
	try
	{
		data.resize(file->GetSize());
	}
	catch (GOrgueOutOfMemory e)
	{
		wxLogError(_("Failed to load file '%s' into the memory"), file->GetName().c_str());
		file->Close();
		return false;
	}
	if (!file->Read(data))
	{
		file->Close();
		wxLogError(_("Failed to read file '%s'"), file->GetName().c_str());
		return false;
	}
	file->Close();
	GOrgueHash hash;
	hash.Update(data.get(), data.GetSize());
	m_Hash = hash.getStringHash();

	if (isBufferCompressed(data))
	{
		if (!uncompressBuffer(data))
		{
			wxLogError(_("Failed to decompress file '%s'"), file->GetName().c_str());
			return false;
		}
	}

	wxMBConv* conv;
	wxCSConv isoConv(wxT("ISO-8859-1"));
	uint8_t* dataPtr = data.get();
	size_t length = data.GetCount();
	if (length >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF)
	{
		conv = &wxConvUTF8;
		dataPtr = data.get() + 3;
		length -= 3;
	}
	else
		conv = &isoConv;
	wxString input((const char*)dataPtr, *conv, length);
	data.free();
	if (length && input.Len() == 0)
	{
		wxLogError(_("Failed to decode file '%s'"), file->GetName().c_str());
		return false;
	}
	
	unsigned pos = 0;
	wxString group;
	std::map<wxString, wxString>* grp = NULL;
	unsigned lineno = 0;
	
	while(pos < input.Len())
	{
		wxString line = GetNextLine(input, pos);
		lineno++;
		
		if (line == wxEmptyString)
			continue;
		if (line.Len() >= 1 && line[0] == wxT(';'))
			continue;
		if (line.Len() > 1 && line[0] == wxT('['))
		{
			if (line[line.Len() - 1] != wxT(']'))
			{
				line = line.Trim();
				if (line[line.Len() - 1] != wxT(']'))
				{
					wxLogError(_("Invalid Config entry at line %d: %s"), lineno, line.c_str());
					continue;
				}
				wxLogError(_("Invalid section start at line %d: %s"), lineno, line.c_str());
			}
			group = line.Mid(1, line.Len() - 2);
			if (m_Entries.find(group) != m_Entries.end())
			{
				wxLogWarning(_("Duplicate group at line %d: %s"), lineno, group.c_str());
			}
			grp = &m_Entries[group];
		}
		else
		{
			if (!grp)
			{
				wxLogError(_("Config entry without any group at line %d"), lineno);
				continue;
			}
			int datapos = line.find(wxT("="), 0);
			if (datapos <= 0)
			{
				wxLogError(_("Invalid Config entry at line %d: %s"), lineno, line.c_str());
				continue;
			}
			wxString name = line.Mid(0, datapos);
			if (grp->find(name) != grp->end())
			{
				wxLogWarning(_("Duplicate entry in section %s at line %d: %s"), group.c_str(), lineno, name.c_str());
			}
			(*grp)[name] = line.Mid(datapos + 1);
		}
	}

	return true;
}