Пример #1
0
int eRawFile::switchOffset(off_t off)
{
	if (m_splitsize)
	{
		int filenr = off / m_splitsize;
		if (filenr >= m_nrfiles)
			filenr = m_nrfiles - 1;
		if (filenr != m_current_file)
		{	
//			eDebug("-> %d", filenr);
			close();
			m_fd = openFileUncached(filenr);
			m_last_offset = m_base_offset = m_splitsize * filenr;
			m_current_file = filenr;
		}
	} else
		m_base_offset = 0;
	
	if (off != m_last_offset)
	{
		m_last_offset = ::lseek(m_fd, off - m_base_offset, SEEK_SET) + m_base_offset;
		return m_last_offset;
	} else
	{
		return m_last_offset;
	}
}
Пример #2
0
void eRawFile::scan()
{
	m_nrfiles = 0;
	m_totallength = 0;
	while (m_nrfiles < 1000) /* .999 is the last possible */
	{
		if (!m_cached)
		{
			int f = openFileUncached(m_nrfiles);
			if (f < 0)
				break;
			if (!m_nrfiles)
				m_splitsize = ::lseek(f, 0, SEEK_END);
			m_totallength += ::lseek(f, 0, SEEK_END);
			::close(f);
		} else
		{
			FILE *f = openFileCached(m_nrfiles);
			if (!f)
				break;
			::fseeko(f, 0, SEEK_END);
			if (!m_nrfiles)
				m_splitsize = ::ftello(f);
			m_totallength += ::ftello(f);
			::fclose(f);
		}
		
		++m_nrfiles;
	}
//	eDebug("found %d files, splitsize: %llx, totallength: %llx", m_nrfiles, m_splitsize, m_totallength);
}