Esempio n. 1
0
emu_file::operator core_file *()
{
    // load the ZIP file now if we haven't yet
    if (compressed_file_ready())
        return NULL;

    // return the core file
    return m_file;
}
Esempio n. 2
0
emu_file::operator util::core_file &()
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		throw emu_fatalerror("operator core_file & used on invalid file");

	// return the core file
	return *m_file;
}
Esempio n. 3
0
int emu_file::ungetc(int c)
{
    // load the ZIP file now if we haven't yet
    if (compressed_file_ready())
        return 1;

    // read the data if we can
    if (m_file != NULL)
        return core_ungetc(c, m_file);

    return 1;
}
Esempio n. 4
0
UINT64 emu_file::tell()
{
    // load the ZIP file now if we haven't yet
    if (compressed_file_ready())
        return 0;

    // tell if we can
    if (m_file != NULL)
        return core_ftell(m_file);

    return 0;
}
Esempio n. 5
0
int emu_file::getc()
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return EOF;

	// read the data if we can
	if (m_file != nullptr)
		return core_fgetc(m_file);

	return EOF;
}
Esempio n. 6
0
UINT32 emu_file::read(void *buffer, UINT32 length)
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 0;

	// read the data if we can
	if (m_file != nullptr)
		return core_fread(m_file, buffer, length);

	return 0;
}
Esempio n. 7
0
bool emu_file::eof()
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 0;

	// return EOF if we can
	if (m_file != nullptr)
		return core_feof(m_file);

	return 0;
}
Esempio n. 8
0
int emu_file::seek(INT64 offset, int whence)
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 1;

	// seek if we can
	if (m_file != nullptr)
		return core_fseek(m_file, offset, whence);

	return 1;
}
Esempio n. 9
0
char *emu_file::gets(char *s, int n)
{
    // load the ZIP file now if we haven't yet
    if (compressed_file_ready())
        return NULL;

    // read the data if we can
    if (m_file != NULL)
        return core_fgets(s, n, m_file);

    return NULL;
}
Esempio n. 10
0
char *emu_file::gets(char *s, int n)
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return nullptr;

	// read the data if we can
	if (m_file)
		return m_file->gets(s, n);

	return nullptr;
}
Esempio n. 11
0
int emu_file::getc()
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return EOF;

	// read the data if we can
	if (m_file)
		return m_file->getc();

	return EOF;
}
Esempio n. 12
0
int emu_file::ungetc(int c)
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 1;

	// read the data if we can
	if (m_file)
		return m_file->ungetc(c);

	return 1;
}
Esempio n. 13
0
UINT32 emu_file::read(void *buffer, UINT32 length)
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 0;

	// read the data if we can
	if (m_file)
		return m_file->read(buffer, length);

	return 0;
}
Esempio n. 14
0
bool emu_file::eof()
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 0;

	// return EOF if we can
	if (m_file)
		return m_file->eof();

	return 0;
}
Esempio n. 15
0
UINT64 emu_file::tell()
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 0;

	// tell if we can
	if (m_file)
		return m_file->tell();

	return 0;
}
Esempio n. 16
0
int emu_file::seek(INT64 offset, int whence)
{
	// load the ZIP file now if we haven't yet
	if (compressed_file_ready())
		return 1;

	// seek if we can
	if (m_file)
		return m_file->seek(offset, whence);

	return 1;
}
Esempio n. 17
0
hash_collection &emu_file::hashes(const char *types)
{
	// determine the hashes we already have
	std::string already_have;
	m_hashes.hash_types(already_have);

	// determine which hashes we need
	std::string needed;
	for (const char *scan = types; *scan != 0; scan++)
		if (already_have.find_first_of(*scan) == -1)
			needed.push_back(*scan);

	// if we need nothing, skip it
	if (needed.empty())
		return m_hashes;

	// load the ZIP file if needed
	if (compressed_file_ready())
		return m_hashes;
	if (m_file == nullptr)
		return m_hashes;

	// if we have ZIP data, just hash that directly
	if (!m__7zdata.empty())
	{
		m_hashes.compute(&m__7zdata[0], m__7zdata.size(), needed.c_str());
		return m_hashes;
	}

	if (!m_zipdata.empty())
	{
		m_hashes.compute(&m_zipdata[0], m_zipdata.size(), needed.c_str());
		return m_hashes;
	}

	// read the data if we can
	const UINT8 *filedata = (const UINT8 *)core_fbuffer(m_file);
	if (filedata == nullptr)
		return m_hashes;

	// compute the hash
	m_hashes.compute(filedata, core_fsize(m_file), needed.c_str());
	return m_hashes;
}
Esempio n. 18
0
hash_collection &emu_file::hashes(const char *types)
{
    // determine the hashes we already have
    astring already_have;
    m_hashes.hash_types(already_have);

    // determine which hashes we need
    astring needed;
    for (const char *scan = types; *scan != 0; scan++)
        if (already_have.chr(0, *scan) == -1)
            needed.cat(*scan);

    // if we need nothing, skip it
    if (!needed)
        return m_hashes;

    // load the ZIP file if needed
    if (compressed_file_ready())
        return m_hashes;
    if (m_file == NULL)
        return m_hashes;

    // if we have ZIP data, just hash that directly
    if (m__7zdata.count() != 0)
    {
        m_hashes.compute(m__7zdata, m__7zdata.count(), needed);
        return m_hashes;
    }

    if (m_zipdata.count() != 0)
    {
        m_hashes.compute(m_zipdata, m_zipdata.count(), needed);
        return m_hashes;
    }

    // read the data if we can
    const UINT8 *filedata = (const UINT8 *)core_fbuffer(m_file);
    if (filedata == NULL)
        return m_hashes;

    // compute the hash
    m_hashes.compute(filedata, core_fsize(m_file), needed);
    return m_hashes;
}