Exemple #1
0
static zip_error get_compressed_data_offset(zip_file *zip, UINT64 *offset)
{
	file_error error;
	UINT32 read_length;

	/* make sure the file handle is open */
	if (zip->file == nullptr)
	{
		int filerr = osd_open(zip->filename, OPEN_FLAG_READ, &zip->file, &zip->length);
		if (filerr != FILERR_NONE)
			return ZIPERR_FILE_ERROR;
	}

	/* now go read the fixed-sized part of the local file header */
	error = osd_read(zip->file, zip->buffer, zip->header.local_header_offset, ZIPNAME, &read_length);
	if (error != FILERR_NONE || read_length != ZIPNAME)
		return (error == FILERR_NONE) ? ZIPERR_FILE_TRUNCATED : ZIPERR_FILE_ERROR;

	/* compute the final offset */
	*offset = zip->header.local_header_offset + ZIPNAME;
	*offset += read_word(zip->buffer + ZIPFNLN);
	*offset += read_word(zip->buffer + ZIPXTRALN);

	return ZIPERR_NONE;
}
Exemple #2
0
_7z_error _7z_file_decompress(_7z_file *new_7z, void *buffer, UINT32 length)
{
	file_error err;
	SRes res;
	int index = new_7z->curr_file_idx;

	/* make sure the file is open.. */
	if (new_7z->archiveStream.file._7z_osdfile==NULL)
	{
		new_7z->archiveStream.file._7z_currfpos = 0;
		err = osd_open(new_7z->filename, OPEN_FLAG_READ, &new_7z->archiveStream.file._7z_osdfile, &new_7z->archiveStream.file._7z_length);
		if (err != FILERR_NONE)
			return _7ZERR_FILE_ERROR;
	}

	size_t offset = 0;
	size_t outSizeProcessed = 0;

	res = SzArEx_Extract(&new_7z->db, &new_7z->lookStream.s, index,
		&new_7z->blockIndex, &new_7z->outBuffer, &new_7z->outBufferSize,
		&offset, &outSizeProcessed,
		&new_7z->allocImp, &new_7z->allocTempImp);

	if (res != SZ_OK)
		return _7ZERR_FILE_ERROR;

	memcpy(buffer, new_7z->outBuffer + offset, length);

	return _7ZERR_NONE;
}
Exemple #3
0
static UINT64 get_file_size(const char *filename)
{
    osd_file *file;
    UINT64 filesize = 0;
    file_error filerr;

    filerr = osd_open(filename, OPEN_FLAG_READ, &file, &filesize);
    if (filerr == FILERR_NONE)
        osd_close(file);
    return filesize;
}
Exemple #4
0
file_error osd_openpty(osd_file **file, char *name, size_t name_len)
{
        file_error res;
        UINT64 filesize;

        if ((res = osd_open(sdlfile_ptty_identifier , 0 , file , &filesize)) != FILERR_NONE) {
                return res;
        }

        if ((res = sdl_slave_name_ptty(*file , name , name_len)) != FILERR_NONE) {
                osd_close(*file);
        }

        return res;
}
Exemple #5
0
file_error core_fopen(const char *filename, UINT32 openflags, core_file **file)
{
	file_error filerr = FILERR_NOT_FOUND;

	/* allocate the file itself */
	*file = (core_file *)malloc(sizeof(**file));
	if (*file == NULL)
		return FILERR_OUT_OF_MEMORY;
	memset(*file, 0, sizeof(**file));

	/* attempt to open the file */
	filerr = osd_open(filename, openflags, &(*file)->file, &(*file)->length);
	(*file)->openflags = openflags;

	/* handle errors and return */
	if (filerr != FILERR_NONE)
	{
		core_fclose(*file);
		*file = NULL;
	}
	return filerr;
}
int main()
{
	int ret = 0;
	const char *root = "/tmp/osd/";
	struct osd_device osd;

	system("rm -rf /tmp/osd");
	ret = osd_open(root, &osd);
	assert(ret == 0);
	
	test_set_one_attr(&osd); 
	/* test_partition(&osd); */
	/* test_create(&osd); */
	/* test_query(&osd); */
	/* test_list(&osd); */
	/* test_set_member_attributes(&osd); */
	/* test_atomics(&osd); */

	ret = osd_close(&osd);
	assert(ret == 0);

	return 0;
}
Exemple #7
0
static void identify_file(const char *name, romident_status *status)
{
	file_error filerr;
	osd_file *file;
	UINT64 length;

	/* open for read and process if it opens and has a valid length */
	filerr = osd_open(name, OPEN_FLAG_READ, &file, &length);
	if (filerr == FILERR_NONE && length > 0 && (UINT32)length == length)
	{
		UINT8 *data = (UINT8 *)malloc(length);
		if (data != NULL)
		{
			UINT32 bytes;

			/* read file data into RAM and identify it */
			filerr = osd_read(file, data, 0, length, &bytes);
			if (filerr == FILERR_NONE)
				identify_data(name, data, bytes, status);
			free(data);
		}
		osd_close(file);
	}
}
int main(int argc, char **argv)
{
	int numiter = 100;
	int numobj = 200;
	int numobj_in_coll = 100;
	int nummatch = 20;
	int numattr = 10;
	int numcriteria = 3;
	static struct osd_device osd;
	int ret;

	osd_set_progname(argc, argv);
	while (++argv, --argc > 0) {
		const char *s = *argv;
		if (s[0] == '-') {
			switch (s[1]) {
			case 'i':
				++argv, --argc;
				if (argc < 1)
					usage();
				numiter = atoi(*argv);
				break;
			case 'o':
				++argv, --argc;
				if (argc < 1)
					usage();
				numobj = atoi(*argv);
				break;
			case 'c':
				++argv, --argc;
				if (argc < 1)
					usage();
				numobj_in_coll = atoi(*argv);
				break;
			case 'm':
				++argv, --argc;
				if (argc < 1)
					usage();
				nummatch = atoi(*argv);
				break;
			case 'a':
				++argv, --argc;
				if (argc < 1)
					usage();
				numattr = atoi(*argv);
				break;
			case 'n':
				++argv, --argc;
				if (argc < 1)
					usage();
				numcriteria = atoi(*argv);
				break;
			default:
				usage();
			}
		} else
			usage();
	}

	system("rm -rf /tmp/osd");
	ret = osd_open("/tmp/osd", &osd);
	assert(ret == 0);

	query_speed(&osd, numiter, numobj, numobj_in_coll, nummatch,
		    numattr, numcriteria);

	ret = osd_close(&osd);
	assert(ret == 0);

	return 0;
}
Exemple #9
0
_7z_error _7z_file_open(const char *filename, _7z_file **_7z)
{
	file_error err;
	_7z_error _7zerr = _7ZERR_NONE;


	_7z_file *new_7z;
	char *string;
	int cachenum;

	SRes res;

	/* ensure we start with a NULL result */
	*_7z = NULL;

	/* see if we are in the cache, and reopen if so */
	for (cachenum = 0; cachenum < ARRAY_LENGTH(_7z_cache); cachenum++)
	{
		_7z_file *cached = _7z_cache[cachenum];

		/* if we have a valid entry and it matches our filename, use it and remove from the cache */
		if (cached != NULL && cached->filename != NULL && strcmp(filename, cached->filename) == 0)
		{
			*_7z = cached;
			_7z_cache[cachenum] = NULL;
			return _7ZERR_NONE;
		}
	}

	/* allocate memory for the _7z_file structure */
	new_7z = (_7z_file *)malloc(sizeof(*new_7z));
	if (new_7z == NULL)
		return _7ZERR_OUT_OF_MEMORY;
	memset(new_7z, 0, sizeof(*new_7z));

	new_7z->inited = false;
	new_7z->archiveStream.file._7z_currfpos = 0;
	err = osd_open(filename, OPEN_FLAG_READ, &new_7z->archiveStream.file._7z_osdfile, &new_7z->archiveStream.file._7z_length);
	if (err != FILERR_NONE)
	{
		_7zerr = _7ZERR_FILE_ERROR;
		goto error;
	}

	new_7z->allocImp.Alloc = SZipAlloc;
	new_7z->allocImp.Free = SZipFree;

	new_7z->allocTempImp.Alloc = SZipAlloc;
	new_7z->allocTempImp.Free = SZipFree;

	if (InFile_Open(&new_7z->archiveStream.file, filename))
	{
		_7zerr = _7ZERR_FILE_ERROR;
		goto error;
	}

	FileInStream_CreateVTable(&new_7z->archiveStream);
	LookToRead_CreateVTable(&new_7z->lookStream, False);

	new_7z->lookStream.realStream = &new_7z->archiveStream.s;
	LookToRead_Init(&new_7z->lookStream);

	CrcGenerateTable();

	SzArEx_Init(&new_7z->db);
	new_7z->inited = true;

	res = SzArEx_Open(&new_7z->db, &new_7z->lookStream.s, &new_7z->allocImp, &new_7z->allocTempImp);
	if (res != SZ_OK)
	{
		_7zerr = _7ZERR_FILE_ERROR;
		goto error;
	}

	new_7z->blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
	new_7z->outBuffer = 0; /* it must be 0 before first call for each new archive. */
	new_7z->outBufferSize = 0;  /* it can have any value before first call (if outBuffer = 0) */

	/* make a copy of the filename for caching purposes */
	string = (char *)malloc(strlen(filename) + 1);
	if (string == NULL)
	{
		_7zerr = _7ZERR_OUT_OF_MEMORY;
		goto error;
	}
	strcpy(string, filename);
	new_7z->filename = string;
	*_7z = new_7z;
	return _7ZERR_NONE;

error:
	free__7z_file(new_7z);
	return _7zerr;
}
int main(int argc, char **argv)
{
	int ret = 0;
	int numobj = 10;
	int numiter = 10;
	int numattr = 10;
	int numpg = 10;
	const char *root = "/tmp/osd/";
	const char *func = NULL;
	struct osd_device osd;

	osd_set_progname(argc, argv);
	while (++argv, --argc > 0) {
		const char *s = *argv;
		if (s[0] == '-') {
			switch (s[1]) {
			case 'i':
				++argv, --argc;
				if (argc < 1)
					usage();
				numiter = atoi(*argv);
				break;
			case 'o':
				++argv, --argc;
				if (argc < 1)
					usage();
				numobj = atoi(*argv);
				break;
			case 'a':
				++argv, --argc;
				if (argc < 1)
					usage();
				numattr = atoi(*argv);
				break;
			case 'p':
				++argv, --argc;
				if (argc < 1)
					usage();
				numpg = atoi(*argv);
				break;
			case 't':
				++argv, --argc;
				if (argc < 1)
					usage();
				func = *argv;
				break;
			default:
				usage();
			}
		}
	}

	if (!func)
		usage();

	system("rm -rf /tmp/osd/*");
	ret = osd_open(root, &osd);
	assert(ret == 0);

  	if (!strcmp(func, "collinsert")) {
		time_coll_insert(&osd, numobj, numiter, 0);
	} else if (!strcmp(func, "collinsertone")) {
		time_coll_insert(&osd, numobj, numiter, 1);
	} else if (!strcmp(func, "colldelete")) {
		time_coll_delete(&osd, numobj, numiter, 0);
	} else if (!strcmp(func, "colldeleteone")) {
		time_coll_delete(&osd, numobj, numiter, 1);
	} else if (!strcmp(func, "objinsert")) {
		time_obj_insert(&osd, numobj, numiter, 0);
	} else if (!strcmp(func, "objinsertone")) {
		time_obj_insert(&osd, numobj, numiter, 1);
	} else if (!strcmp(func, "objdelete")) {
		time_obj_delete(&osd, numobj, numiter, 0);
	} else if (!strcmp(func, "objdeleteone")) {
		time_obj_delete(&osd, numobj, numiter, 1);
	} else if (!strcmp(func, "objdelpid")) {
		time_obj_delpid(&osd, numobj, numiter);
	} else if (!strcmp(func, "objnextpid")) {
		time_obj_generic(&osd, numobj, numiter, 1);
	} else if (!strcmp(func, "objnextoid")) {
		time_obj_generic(&osd, numobj, numiter, 2);
	} else if (!strcmp(func, "objpresent")) {
		time_obj_generic(&osd, numobj, numiter, 3);
	} else if (!strcmp(func, "objnotpresent")) {
		time_obj_generic(&osd, numobj, numiter, 4);
	} else if (!strcmp(func, "objpidempty")) {
		time_obj_generic(&osd, numobj, numiter, 5);
	} else if (!strcmp(func, "objgettype")) {
		time_obj_generic(&osd, numobj, numiter, 6);
	} else if (!strcmp(func, "objgetoids")) {
		time_obj_fetch(&osd, numobj, numiter, 1);
	} else if (!strcmp(func, "objgetcids")) {
		time_obj_fetch(&osd, numobj, numiter, 2);
	} else if (!strcmp(func, "objgetpids")) {
		time_obj_fetch(&osd, numobj, numiter, 3);
	} else if (!strcmp(func, "objgetfullpids")) {
		time_obj_fetch(&osd, numobj, numiter, 4);
	} else if (!strcmp(func, "attrsetone")) {
		time_attr(&osd, numpg, numattr, numiter, 1, func);
	} else if (!strcmp(func, "attrgetone")) {
		time_attr(&osd, numpg, numattr, numiter, 2, func);
	} else if (!strcmp(func, "attrdelone")) {
		time_attr(&osd, numpg, numattr, numiter, 3, func);
	} else if (!strcmp(func, "attrset")) {
		time_attr(&osd, numpg, numattr, numiter, 4, func);
	} else if (!strcmp(func, "attrget")) {
		time_attr(&osd, numpg, numattr, numiter, 5, func);
	} else if (!strcmp(func, "attrdel")) {
		time_attr(&osd, numpg, numattr, numiter, 6, func);
	} else if (!strcmp(func, "attrdirpg")) {
		time_attr(&osd, numpg, numattr, numiter, 7, func);
	} else if (!strcmp(func, "attrforallpg")) {
		time_attr(&osd, numpg, numattr, numiter, 8, func);
	} else if (!strcmp(func, "attrpgaslst")) {
		time_attr(&osd, numpg, numattr, numiter, 9, func);
	} else {
		usage();
	} 

	ret = osd_close(&osd);
	assert(ret == 0);

	return 0;
}
Exemple #11
0
/*-------------------------------------------------
    parse_wav_sample - takes a .WAV file, verifies
    that the file is 16 bits, and returns the
    length in bytes of the data and the offset in
    bytes to where the data starts in the file.
-------------------------------------------------*/
static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
{
	unsigned long offset = 0;
	UINT32 length, rate, filesize;
	UINT16 bits, temp16;
	char buf[32];
	osd_file *file;
	file_error filerr;
	UINT64 fsize = 0;
	UINT32 actual;

	filerr = osd_open(filename, OPEN_FLAG_READ, &file, &fsize);
	if (filerr != FILERR_NONE)
	{
		printf("ERROR: could not open (%s)\n", filename);
		return 0;
	}

	/* read the core header and make sure it's a WAVE file */
	osd_read(file, buf, 0, 4, &actual);
	offset += actual;
	if (offset < 4)
	{
		osd_close(file);
		printf("ERROR: unexpected RIFF offset %lu (%s)\n", offset, filename);
		return 0;
	}
	if (memcmp(&buf[0], "RIFF", 4) != 0)
	{
		osd_close(file);
		printf("ERROR: could not find RIFF header (%s)\n", filename);
		return 0;
	}

	/* get the total size */
	osd_read(file, &filesize, offset, 4, &actual);
	offset += actual;
	if (offset < 8)
	{
		osd_close(file);
		printf("ERROR: unexpected size offset %lu (%s)\n", offset, filename);
		return 0;
	}
	filesize = LITTLE_ENDIANIZE_INT32(filesize);

	/* read the RIFF file type and make sure it's a WAVE file */
	osd_read(file, buf, offset, 4, &actual);
	offset += actual;
	if (offset < 12)
	{
		osd_close(file);
		printf("ERROR: unexpected WAVE offset %lu (%s)\n", offset, filename);
		return 0;
	}
	if (memcmp(&buf[0], "WAVE", 4) != 0)
	{
		osd_close(file);
		printf("ERROR: could not find WAVE header (%s)\n", filename);
		return 0;
	}

	/* seek until we find a format tag */
	while (1)
	{
		osd_read(file, buf, offset, 4, &actual);
		offset += actual;
		osd_read(file, &length, offset, 4, &actual);
		offset += actual;
		length = LITTLE_ENDIANIZE_INT32(length);
		if (memcmp(&buf[0], "fmt ", 4) == 0)
			break;

		/* seek to the next block */
		offset += length;
		if (offset >= filesize)
		{
			osd_close(file);
			printf("ERROR: could not find fmt tag (%s)\n", filename);
			return 0;
		}
	}

	/* read the format -- make sure it is PCM */
	osd_read(file, &temp16, offset, 2, &actual);
	offset += actual;
	temp16 = LITTLE_ENDIANIZE_INT16(temp16);
	if (temp16 != 1)
	{
		osd_close(file);
		printf("ERROR: unsupported format %u - only PCM is supported (%s)\n", temp16, filename);
		return 0;
	}

	/* number of channels -- only stereo is supported */
	osd_read(file, &temp16, offset, 2, &actual);
	offset += actual;
	temp16 = LITTLE_ENDIANIZE_INT16(temp16);
	if (temp16 != 2)
	{
		osd_close(file);
		printf("ERROR: unsupported number of channels %u - only stereo is supported (%s)\n", temp16, filename);
		return 0;
	}

	/* sample rate */
	osd_read(file, &rate, offset, 4, &actual);
	offset += actual;
	rate = LITTLE_ENDIANIZE_INT32(rate);
	if (rate != 44100)
	{
		osd_close(file);
		printf("ERROR: unsupported samplerate %u - only 44100 is supported (%s)\n", rate, filename);
		return 0;
	}

	/* bytes/second and block alignment are ignored */
	osd_read(file, buf, offset, 6, &actual);
	offset += actual;

	/* bits/sample */
	osd_read(file, &bits, offset, 2, &actual);
	offset += actual;
	if (bits != 16)
	{
		osd_close(file);
		printf("ERROR: unsupported bits/sample %u - only 16 is supported (%s)\n", bits, filename);
		return 0;
	}

	/* seek past any extra data */
	offset += length - 16;

	/* seek until we find a data tag */
	while (1)
	{
		osd_read(file, buf, offset, 4, &actual);
		offset += actual;
		osd_read(file, &length, offset, 4, &actual);
		offset += actual;
		length = LITTLE_ENDIANIZE_INT32(length);
		if (memcmp(&buf[0], "data", 4) == 0)
			break;

		/* seek to the next block */
		offset += length;
		if (offset >= filesize)
		{
			osd_close(file);
			printf("ERROR: could not find data tag (%s)\n", filename);
			return 0;
		}
	}

	osd_close(file);

	/* if there was a 0 length data block, we're done */
	if (length == 0)
	{
		printf("ERROR: empty data block (%s)\n", filename);
		return 0;
	}

	*dataoffs = offset;

	return length;
}
Exemple #12
0
static image_error_t load_image_by_path(mess_image *image, const char *software_path,
	const game_driver *gamedrv, UINT32 open_flags, const char *path)
{
	mame_file_error filerr = FILERR_NOT_FOUND;
	image_error_t err = IMAGE_ERROR_FILENOTFOUND;
	char *full_path = NULL;
	const char *file_extension;

	/* assemble the path */
	if (software_path)
	{
		full_path = assemble_5_strings(software_path, PATH_SEPARATOR, gamedrv->name, PATH_SEPARATOR, path);
		path = full_path;
	}

	/* quick check to see if the file is a ZIP file */
	file_extension = strrchr(path, '.');
	if (!file_extension || mame_stricmp(file_extension, ".zip"))
	{
		filerr = osd_open(path, open_flags, &image->file, &image->length);

		/* did the open succeed? */
		switch(filerr)
		{
			case FILERR_NONE:
				/* success! */
				image->writeable = (open_flags & OPEN_FLAG_WRITE) ? 1 : 0;
				image->created = (open_flags & OPEN_FLAG_CREATE) ? 1 : 0;
				err = IMAGE_ERROR_SUCCESS;
				break;

			case FILERR_NOT_FOUND:
			case FILERR_ACCESS_DENIED:
				/* file not found (or otherwise cannot open); continue */
				err = IMAGE_ERROR_FILENOTFOUND;
				break;

			case FILERR_OUT_OF_MEMORY:
				/* out of memory */
				err = IMAGE_ERROR_OUTOFMEMORY;
				break;

			case FILERR_ALREADY_OPEN:
				/* this shouldn't happen */
				err = IMAGE_ERROR_ALREADYOPEN;
				break;

			case FILERR_FAILURE:
			case FILERR_TOO_MANY_FILES:
			case FILERR_INVALID_DATA:
			default:
				/* other errors */
				err = IMAGE_ERROR_INTERNAL;
				break;
		}
	}

	/* special case for ZIP files */
	if ((err == IMAGE_ERROR_FILENOTFOUND) && (open_flags == OPEN_FLAG_READ))
		err = load_zip_path(image, path);

	/* check to make sure that our reported error is reflective of the actual status */
	if (err)
		assert(!is_loaded(image));
	else
		assert(is_loaded(image));

	/* free up memory, and exit */
	if (full_path)
		free(full_path);
	return err;
}
Exemple #13
0
zip_error zip_file_open(const char *filename, zip_file **zip)
{
	zip_error ziperr = ZIPERR_NONE;
	file_error filerr;
	UINT32 read_length;
	zip_file *newzip;
	char *string;
	int cachenum;

	/* ensure we start with a NULL result */
	*zip = nullptr;

	/* see if we are in the cache, and reopen if so */
	for (cachenum = 0; cachenum < ARRAY_LENGTH(zip_cache); cachenum++)
	{
		zip_file *cached = zip_cache[cachenum];

		/* if we have a valid entry and it matches our filename, use it and remove from the cache */
		if (cached != nullptr && cached->filename != nullptr && strcmp(filename, cached->filename) == 0)
		{
			*zip = cached;
			zip_cache[cachenum] = nullptr;
			return ZIPERR_NONE;
		}
	}

	/* allocate memory for the zip_file structure */
	newzip = (zip_file *)malloc(sizeof(*newzip));
	if (newzip == nullptr)
		return ZIPERR_OUT_OF_MEMORY;
	memset(newzip, 0, sizeof(*newzip));

	/* open the file */
	filerr = osd_open(filename, OPEN_FLAG_READ, &newzip->file, &newzip->length);
	if (filerr != FILERR_NONE)
	{
		ziperr = ZIPERR_FILE_ERROR;
		goto error;
	}

	/* read ecd data */
	ziperr = read_ecd(newzip);
	if (ziperr != ZIPERR_NONE)
		goto error;

	/* verify that we can work with this zipfile (no disk spanning allowed) */
	if (newzip->ecd.disk_number != newzip->ecd.cd_start_disk_number || newzip->ecd.cd_disk_entries != newzip->ecd.cd_total_entries)
	{
		ziperr = ZIPERR_UNSUPPORTED;
		goto error;
	}

	/* allocate memory for the central directory */
	newzip->cd = (UINT8 *)malloc(newzip->ecd.cd_size + 1);
	if (newzip->cd == nullptr)
	{
		ziperr = ZIPERR_OUT_OF_MEMORY;
		goto error;
	}

	/* read the central directory */
	filerr = osd_read(newzip->file, newzip->cd, newzip->ecd.cd_start_disk_offset, newzip->ecd.cd_size, &read_length);
	if (filerr != FILERR_NONE || read_length != newzip->ecd.cd_size)
	{
		ziperr = (filerr == FILERR_NONE) ? ZIPERR_FILE_TRUNCATED : ZIPERR_FILE_ERROR;
		goto error;
	}

	/* make a copy of the filename for caching purposes */
	string = (char *)malloc(strlen(filename) + 1);
	if (string == nullptr)
	{
		ziperr = ZIPERR_OUT_OF_MEMORY;
		goto error;
	}
	strcpy(string, filename);
	newzip->filename = string;
	*zip = newzip;
	return ZIPERR_NONE;

error:
	free_zip_file(newzip);
	return ziperr;
}
Exemple #14
0
static void identify_file(core_options *options, const char *name, romident_status *status)
{
	file_error filerr;
	osd_file *file;
	UINT64 length;

	if (core_filename_ends_with(name, ".chd"))
	{
		chd_file *chd;
		chd_error err;
		astring basename;
		int found = 0;

		core_filename_extract_base(&basename, name, FALSE);
		mame_printf_info("%-20s", basename.cstr());

		status->total++;

		err = chd_open(name, CHD_OPEN_READ, NULL, &chd);
		if (err != CHDERR_NONE)
		{
			mame_printf_info("NOT A CHD\n");
			status->nonroms++;
		}
		else
		{
			chd_header header;

			header = *chd_get_header(chd);
			if (header.flags & CHDFLAGS_IS_WRITEABLE)
			{
				mame_printf_info("is a writable CHD\n");
			}
			else
			{
				static const UINT8 nullhash[HASH_BUF_SIZE] = { 0 };
				char			hash[HASH_BUF_SIZE];	/* actual hash information */

				hash_data_clear(hash);

				/* if there's an MD5 or SHA1 hash, add them to the output hash */
				if (memcmp(nullhash, header.md5, sizeof(header.md5)) != 0)
					hash_data_insert_binary_checksum(hash, HASH_MD5, header.md5);
				if (memcmp(nullhash, header.sha1, sizeof(header.sha1)) != 0)
					hash_data_insert_binary_checksum(hash, HASH_SHA1, header.sha1);

				length = header.logicalbytes;

				match_roms(options, hash, length, &found);

				if (found == 0)
				{
					mame_printf_info("NO MATCH\n");
				}

				/* if we did find it, count it as a match */
				else
					status->matches++;
			}

			chd_close(chd);
		}
	}
	else
	{
		/* open for read and process if it opens and has a valid length */
		filerr = osd_open(name, OPEN_FLAG_READ, &file, &length);
		if (filerr == FILERR_NONE && length > 0 && (UINT32)length == length)
		{
			UINT8 *data = global_alloc_array(UINT8, length);
			if (data != NULL)
			{
				UINT32 bytes;

				/* read file data into RAM and identify it */
				filerr = osd_read(file, data, 0, length, &bytes);
				if (filerr == FILERR_NONE)
					identify_data(options, name, data, bytes, status);
				global_free(data);
			}
			osd_close(file);
		}
	}
}