Example #1
0
/*
    imghd_open()

    Open stream as a MAME HD image
*/
imgtoolerr_t imghd_open(imgtool::stream &stream, struct mess_hard_disk_file *hard_disk)
{
	chd_error chderr;
	imgtoolerr_t err = IMGTOOLERR_SUCCESS;

	hard_disk->hard_disk = nullptr;
	hard_disk->chd = nullptr;

	chderr = hard_disk->chd->open(*stream.core_file(), stream.is_read_only());
	if (chderr)
	{
		err = map_chd_error(chderr);
		goto done;
	}

	hard_disk->hard_disk = hard_disk_open(hard_disk->chd);
	if (!hard_disk->hard_disk)
	{
		err = IMGTOOLERR_UNEXPECTED;
		goto done;
	}
	hard_disk->stream = &stream;

done:
	if (err)
		imghd_close(hard_disk);
	return err;
}
Example #2
0
/*
	imghd_open()

	Open stream as a MAME HD image
*/
imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard_disk)
{
	imgtoolerr_t err = IMGTOOLERR_SUCCESS;
	char encoded_image_ref[encoded_image_ref_max_len];
	chd_interface interface_save;

	hard_disk->hard_disk = NULL;
	hard_disk->chd = NULL;
	encode_image_ref(stream, encoded_image_ref);

	/* use our CHD interface */
	chd_save_interface(&interface_save);
	chd_set_interface(&imgtool_chd_interface);

	hard_disk->chd = chd_open(encoded_image_ref, !stream_isreadonly(stream), NULL);
	if (!hard_disk->chd)
	{
		err = imghd_chd_getlasterror();
		goto done;
	}

	hard_disk->hard_disk = hard_disk_open(hard_disk->chd);
	if (!hard_disk->hard_disk)
	{
		err = IMGTOOLERR_UNEXPECTED;
		goto done;
	}
	hard_disk->stream = stream;

done:
	if (err)
		imghd_close(hard_disk);
	chd_set_interface(&interface_save);
	return err;
}
Example #3
0
File: imghd.c Project: dinkc64/mame
/*
    imghd_open()

    Open stream as a MAME HD image
*/
imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard_disk)
{
	chd_error chderr;
	imgtoolerr_t err = IMGTOOLERR_SUCCESS;

	hard_disk->hard_disk = NULL;
	hard_disk->chd = NULL;

	chderr = hard_disk->chd->open(*stream_core_file(stream), stream_isreadonly(stream));
	if (chderr)
	{
		err = map_chd_error(chderr);
		goto done;
	}

	hard_disk->hard_disk = hard_disk_open(hard_disk->chd);
	if (!hard_disk->hard_disk)
	{
		err = IMGTOOLERR_UNEXPECTED;
		goto done;
	}
	hard_disk->stream = stream;

done:
	if (err)
		imghd_close(hard_disk);
	return err;
}
Example #4
0
/*
	imghd_open()

	Open stream as a MAME HD image
*/
imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard_disk)
{
	chd_error chderr;
	imgtoolerr_t err = IMGTOOLERR_SUCCESS;
	char encoded_image_ref[encoded_image_ref_max_len];
	chd_interface interface_save;

	hard_disk->hard_disk = NULL;
	hard_disk->chd = NULL;
	encode_image_ref(stream, encoded_image_ref);

	/* use our CHD interface */
	chd_save_interface(&interface_save);
	chd_set_interface(&imgtool_chd_interface);

	chderr = chd_open(encoded_image_ref, stream_isreadonly(stream) ? CHD_OPEN_READ : CHD_OPEN_READWRITE, NULL, &hard_disk->chd);
	if (chderr)
	{
		err = map_chd_error(chderr);
		goto done;
	}

	hard_disk->hard_disk = hard_disk_open(hard_disk->chd);
	if (!hard_disk->hard_disk)
	{
		err = IMGTOOLERR_UNEXPECTED;
		goto done;
	}
	hard_disk->stream = stream;

done:
	if (err)
		imghd_close(hard_disk);
	chd_set_interface(&interface_save);
	return err;
}