diff options
Diffstat (limited to 'src/tools/imgtool/modules/rsdos.cpp')
-rw-r--r-- | src/tools/imgtool/modules/rsdos.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/tools/imgtool/modules/rsdos.cpp b/src/tools/imgtool/modules/rsdos.cpp index 4bcde9444ab..b4924338309 100644 --- a/src/tools/imgtool/modules/rsdos.cpp +++ b/src/tools/imgtool/modules/rsdos.cpp @@ -8,13 +8,18 @@ ****************************************************************************/ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> #include "imgtool.h" -#include "formats/coco_dsk.h" +#include "filter.h" #include "iflopimg.h" +#include "formats/coco_dsk.h" +#include "corestr.h" +#include "opresolv.h" + +#include <cstdio> +#include <cstdlib> +#include <cstring> + /* this structure mirrors the structure of an RS-DOS directory entry on disk */ struct rsdos_dirent { @@ -103,7 +108,7 @@ static imgtoolerr_t lookup_rsdos_file(imgtool::image &f, const char *fname, rsdo if (ent.filename[0] != -1) fnamebuf = get_dirent_fname(ent); } - while((ent.filename[0] != -1) && core_stricmp(fnamebuf.c_str(), fname)); + while((ent.filename[0] != -1) && core_stricmp(fnamebuf, fname)); if (ent.filename[0] == -1) return IMGTOOLERR_FILENOTFOUND; @@ -320,7 +325,7 @@ eof: } else { - /* Not the end of file */ + /* Note the end of file */ err = process_rsdos_file(&rsent, image, nullptr, filesize); if (err) return err; @@ -340,8 +345,8 @@ eof: std::string fname = get_dirent_fname(rsent); - snprintf(ent.filename, ARRAY_LENGTH(ent.filename), "%s", fname.c_str()); - snprintf(ent.attr, ARRAY_LENGTH(ent.attr), "%d %c", (int) rsent.ftype, (char) (rsent.asciiflag + 'B')); + snprintf(ent.filename, std::size(ent.filename), "%s", fname.c_str()); + snprintf(ent.attr, std::size(ent.attr), "%d %c", (int) rsent.ftype, (char) (rsent.asciiflag + 'B')); } return IMGTOOLERR_SUCCESS; } @@ -568,7 +573,7 @@ static imgtoolerr_t rsdos_diskimage_deletefile(imgtool::partition &partition, co // rsdos_diskimage_suggesttransfer //------------------------------------------------- -static imgtoolerr_t rsdos_diskimage_suggesttransfer(imgtool::partition &partition, const char *fname, imgtool_transfer_suggestion *suggestions, size_t suggestions_length) +static imgtoolerr_t rsdos_diskimage_suggesttransfer(imgtool::partition &partition, const char *fname, imgtool::transfer_suggestion *suggestions, size_t suggestions_length) { imgtoolerr_t err; imgtool::image &image(partition.image()); @@ -584,27 +589,27 @@ static imgtoolerr_t rsdos_diskimage_suggesttransfer(imgtool::partition &partitio if (ent.asciiflag == (char) 0xFF) { /* ASCII file */ - suggestions[0].viability = SUGGESTION_RECOMMENDED; + suggestions[0].viability = imgtool::SUGGESTION_RECOMMENDED; suggestions[0].filter = filter_eoln_getinfo; - suggestions[1].viability = SUGGESTION_POSSIBLE; - suggestions[1].filter = NULL; + suggestions[1].viability = imgtool::SUGGESTION_POSSIBLE; + suggestions[1].filter = nullptr; } else if (ent.ftype == 0) { /* tokenized BASIC file */ - suggestions[0].viability = SUGGESTION_RECOMMENDED; - suggestions[0].filter = NULL; - suggestions[1].viability = SUGGESTION_POSSIBLE; + suggestions[0].viability = imgtool::SUGGESTION_RECOMMENDED; + suggestions[0].filter = nullptr; + suggestions[1].viability = imgtool::SUGGESTION_POSSIBLE; suggestions[1].filter = filter_cocobas_getinfo; } } else { - suggestions[0].viability = SUGGESTION_RECOMMENDED; - suggestions[0].filter = NULL; - suggestions[1].viability = SUGGESTION_POSSIBLE; + suggestions[0].viability = imgtool::SUGGESTION_RECOMMENDED; + suggestions[0].filter = nullptr; + suggestions[1].viability = imgtool::SUGGESTION_POSSIBLE; suggestions[1].filter = filter_eoln_getinfo; - suggestions[2].viability = SUGGESTION_POSSIBLE; + suggestions[2].viability = imgtool::SUGGESTION_POSSIBLE; suggestions[2].filter = filter_cocobas_getinfo; } @@ -640,7 +645,7 @@ void rsdos_get_info(const imgtool_class *imgclass, uint32_t state, union imgtool case IMGTOOLINFO_INT_PREFER_UCASE: info->i = 1; break; case IMGTOOLINFO_INT_DIRECTORY_EXTRA_BYTES: info->i = sizeof(struct rsdos_direnum); break; - /* --- the following bits of info are returned as NULL-terminated strings --- */ + /* --- the following bits of info are returned as NUL-terminated strings --- */ case IMGTOOLINFO_STR_NAME: strcpy(info->s = imgtool_temp_str(), "rsdos"); break; case IMGTOOLINFO_STR_DESCRIPTION: strcpy(info->s = imgtool_temp_str(), "RS-DOS format"); break; case IMGTOOLINFO_STR_FILE: strcpy(info->s = imgtool_temp_str(), __FILE__); break; |