summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2016-09-10 10:15:30 +1000
committer GitHub <noreply@github.com>2016-09-10 10:15:30 +1000
commit6a2b41aa0b6768e20a5c293a17b1a0443824ca55 (patch)
treee032b0b68489a6dcf4e64d767363b0c96f333f70 /src/lib/formats
parent92f1f661dda002a5731d9709bdc81aabddc4ef2a (diff)
parentb5a2d1bc77fdc51119f6294a79f05fd5fbaf3ef7 (diff)
Merge pull request #1332 from npwoods/option_guide_and_imgtool
option_guide C++-ification, touched up imgtool
Diffstat (limited to 'src/lib/formats')
-rw-r--r--src/lib/formats/flopimg.cpp56
1 files changed, 11 insertions, 45 deletions
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp
index 48240973d3a..82f8d28ca93 100644
--- a/src/lib/formats/flopimg.cpp
+++ b/src/lib/formats/flopimg.cpp
@@ -204,35 +204,9 @@ floperr_t floppy_open_choices(void *fp, const struct io_procs *procs, const std:
-static floperr_t option_to_floppy_error(util::option_resolution::error oerr)
-{
- floperr_t err;
- switch(oerr) {
- case util::option_resolution::error::SUCCESS:
- err = FLOPPY_ERROR_SUCCESS;
- break;
- case util::option_resolution::error::OUTOFMEMORY:
- err = FLOPPY_ERROR_OUTOFMEMORY;
- break;
- case util::option_resolution::error::PARAMOUTOFRANGE:
- case util::option_resolution::error::PARAMNOTSPECIFIED:
- case util::option_resolution::error::PARAMNOTFOUND:
- case util::option_resolution::error::PARAMALREADYSPECIFIED:
- case util::option_resolution::error::BADPARAM:
- case util::option_resolution::error::SYNTAX:
- default:
- err = FLOPPY_ERROR_INTERNAL;
- break;
- };
- return err;
-}
-
-
-
floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, util::option_resolution *parameters, floppy_image_legacy **outfloppy)
{
floppy_image_legacy *floppy = nullptr;
- util::option_resolution::error oerr;
floperr_t err;
int heads, tracks, h, t;
std::unique_ptr<util::option_resolution> alloc_resolution;
@@ -250,26 +224,16 @@ floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct Flo
/* if this format expects creation parameters and none were specified, create some */
if (!parameters && format->param_guidelines)
{
- alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide, format->param_guidelines);
- if (!alloc_resolution)
+ try { alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide); }
+ catch (...)
{
err = FLOPPY_ERROR_OUTOFMEMORY;
goto done;
}
+ alloc_resolution->set_specification(format->param_guidelines);
parameters = alloc_resolution.get();
}
- /* finish the parameters, if specified */
- if (parameters)
- {
- oerr = parameters->finish();
- if (oerr != util::option_resolution::error::SUCCESS)
- {
- err = option_to_floppy_error(oerr);
- goto done;
- }
- }
-
/* call the format constructor */
err = format->construct(floppy, format, parameters);
if (err)
@@ -690,17 +654,19 @@ floperr_t floppy_format_track(floppy_image_legacy *floppy, int head, int track,
/* create a dummy resolution; if no parameters were specified */
if (!parameters)
{
- alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide, floppy->floppy_option->param_guidelines);
- if (!alloc_resolution)
+ try
+ {
+ alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide);
+ }
+ catch (...)
+ {
return FLOPPY_ERROR_OUTOFMEMORY;
+ }
+ alloc_resolution->set_specification(floppy->floppy_option->param_guidelines);
parameters = alloc_resolution.get();
}
- auto oerr = parameters->finish();
- if (oerr != util::option_resolution::error::SUCCESS)
- return option_to_floppy_error(oerr);
-
err = format->format_track(floppy, head, track, parameters);
if (err)
return err;