mirror of
https://github.com/holub/mame
synced 2025-06-20 19:26:42 +03:00
Stop forcing cassette image create when loading zero-length images. Also minor C++-ifications to cassette code (usage of bool and std::string, C++ comments)
This commit is contained in:
parent
27aae4d028
commit
02b9749216
@ -265,26 +265,25 @@ image_init_result cassette_image_device::internal_load(bool is_create)
|
||||
{
|
||||
casserr_t err;
|
||||
int cassette_flags;
|
||||
int is_writable;
|
||||
bool is_writable;
|
||||
device_image_interface *image = nullptr;
|
||||
interface(image);
|
||||
|
||||
if (is_create || (length() == 0))
|
||||
if (is_create)
|
||||
{
|
||||
/* creating an image */
|
||||
// creating an image
|
||||
err = cassette_create((void *)image, &image_ioprocs, &wavfile_format, m_create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &m_cassette);
|
||||
if (err)
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* opening an image */
|
||||
// opening an image
|
||||
do
|
||||
{
|
||||
is_writable = !is_readonly();
|
||||
cassette_flags = is_writable ? (CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT) : CASSETTE_FLAG_READONLY;
|
||||
std::string fname;
|
||||
err = cassette_open_choices((void *)image, &image_ioprocs, filetype().c_str(), m_formats, cassette_flags, &m_cassette);
|
||||
err = cassette_open_choices((void *)image, &image_ioprocs, filetype(), m_formats, cassette_flags, &m_cassette);
|
||||
}
|
||||
while(err && is_writable);
|
||||
|
||||
|
@ -109,18 +109,18 @@ static void cassette_finishinit(casserr_t err, cassette_image *cassette, cassett
|
||||
|
||||
|
||||
|
||||
static int good_format(const struct CassetteFormat *format, const char *extension, int flags)
|
||||
static bool good_format(const struct CassetteFormat *format, const std::string &extension, int flags)
|
||||
{
|
||||
if (extension && !image_find_extension(format->extensions, extension))
|
||||
return FALSE;
|
||||
if (!extension.empty() && !image_find_extension(format->extensions, extension.c_str()))
|
||||
return false;
|
||||
if (((flags & CASSETTE_FLAG_READONLY) == 0) && !format->save)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
casserr_t cassette_open_choices(void *file, const struct io_procs *procs, const char *extension,
|
||||
casserr_t cassette_open_choices(void *file, const struct io_procs *procs, const std::string &extension,
|
||||
const struct CassetteFormat *const *formats, int flags, cassette_image **outcassette)
|
||||
{
|
||||
casserr_t err;
|
||||
|
@ -160,7 +160,7 @@ CASSETTE_FORMATLIST_EXTERN(cassette_default_formats);
|
||||
|
||||
casserr_t cassette_open(void *file, const struct io_procs *procs,
|
||||
const struct CassetteFormat *format, int flags, cassette_image **outcassette);
|
||||
casserr_t cassette_open_choices(void *file, const struct io_procs *procs, const char *extension,
|
||||
casserr_t cassette_open_choices(void *file, const struct io_procs *procs, const std::string &extension,
|
||||
const struct CassetteFormat *const *formats, int flags, cassette_image **outcassette);
|
||||
casserr_t cassette_create(void *file, const struct io_procs *procs, const struct CassetteFormat *format,
|
||||
const struct CassetteOptions *opts, int flags, cassette_image **outcassette);
|
||||
|
Loading…
Reference in New Issue
Block a user