summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/tools/imgtool/filtbas.cpp34
-rw-r--r--src/tools/imgtool/filteoln.cpp22
-rw-r--r--src/tools/imgtool/iflopimg.cpp20
-rw-r--r--src/tools/imgtool/iflopimg.h4
-rw-r--r--src/tools/imgtool/imghd.cpp18
-rw-r--r--src/tools/imgtool/imghd.h4
-rw-r--r--src/tools/imgtool/imgtool.cpp20
-rw-r--r--src/tools/imgtool/imgtool.h8
-rw-r--r--src/tools/imgtool/library.h14
-rw-r--r--src/tools/imgtool/modules/amiga.cpp30
-rw-r--r--src/tools/imgtool/modules/bml3.cpp22
-rw-r--r--src/tools/imgtool/modules/concept.cpp20
-rw-r--r--src/tools/imgtool/modules/cybiko.cpp62
-rw-r--r--src/tools/imgtool/modules/cybikoxt.cpp72
-rw-r--r--src/tools/imgtool/modules/fat.cpp20
-rw-r--r--src/tools/imgtool/modules/hp48.cpp86
-rw-r--r--src/tools/imgtool/modules/hp9845_tape.cpp72
-rw-r--r--src/tools/imgtool/modules/mac.cpp22
-rw-r--r--src/tools/imgtool/modules/macbin.cpp24
-rw-r--r--src/tools/imgtool/modules/os9.cpp14
-rw-r--r--src/tools/imgtool/modules/pc_flop.cpp2
-rw-r--r--src/tools/imgtool/modules/pc_hard.cpp56
-rw-r--r--src/tools/imgtool/modules/prodos.cpp24
-rw-r--r--src/tools/imgtool/modules/psion.cpp172
-rw-r--r--src/tools/imgtool/modules/rsdos.cpp20
-rw-r--r--src/tools/imgtool/modules/thomson.cpp170
-rw-r--r--src/tools/imgtool/modules/ti99.cpp80
-rw-r--r--src/tools/imgtool/modules/ti990hd.cpp46
-rw-r--r--src/tools/imgtool/modules/vzdos.cpp24
29 files changed, 594 insertions, 588 deletions
diff --git a/src/tools/imgtool/filtbas.cpp b/src/tools/imgtool/filtbas.cpp
index 7b87fb4f7e8..539d1cd8ab5 100644
--- a/src/tools/imgtool/filtbas.cpp
+++ b/src/tools/imgtool/filtbas.cpp
@@ -70,7 +70,7 @@ struct basictokens
static imgtoolerr_t basic_readfile(const basictokens *tokens,
imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *destf)
+ const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
imgtool::stream *mem_stream;
@@ -91,7 +91,7 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
}
/* read actual file */
- err = partition->read_file(filename, fork, mem_stream, nullptr);
+ err = partition->read_file(filename, fork, *mem_stream, nullptr);
if (err)
goto done;
@@ -116,7 +116,7 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
}
/* write the line number */
- destf->printf("%u ", (unsigned) line_number);
+ destf.printf("%u ", (unsigned) line_number);
shift = 0x00;
while((mem_stream->read(&b, 1) > 0) && (b != 0x00))
@@ -149,15 +149,15 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
}
if (shift == 0x00)
- destf->puts(token ? token : "!");
+ destf.puts(token ? token : "!");
}
else
{
- destf->putc((char) b);
+ destf.putc((char) b);
}
}
- destf->puts(EOLN);
+ destf.puts(EOLN);
}
done:
@@ -175,7 +175,7 @@ done:
static imgtoolerr_t basic_writefile(const basictokens *tokens,
imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+ const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t err;
imgtool::stream *mem_stream;
@@ -208,7 +208,7 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
{
/* read a line */
pos = 0;
- while((len = sourcef->read(&c, 1)) > 0)
+ while((len = sourcef.read(&c, 1)) > 0)
{
/* break if at end of line */
if ((c == '\r') || (c == '\n'))
@@ -343,7 +343,7 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
}
/* write actual file */
- err = partition->write_file(filename, fork, mem_stream, opts, nullptr);
+ err = partition->write_file(filename, fork, *mem_stream, opts, nullptr);
if (err)
goto done;
@@ -2959,13 +2959,13 @@ static const basictokens cocobas_tokens =
};
static imgtoolerr_t cocobas_readfile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *destf)
+ const char *fork, imgtool::stream &destf)
{
return basic_readfile(&cocobas_tokens, partition, filename, fork, destf);
}
static imgtoolerr_t cocobas_writefile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+ const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
return basic_writefile(&cocobas_tokens, partition, filename, fork, sourcef, opts);
}
@@ -3003,13 +3003,13 @@ static const basictokens dragonbas_tokens =
};
static imgtoolerr_t dragonbas_readfile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *destf)
+ const char *fork, imgtool::stream &destf)
{
return basic_readfile(&dragonbas_tokens, partition, filename, fork, destf);
}
static imgtoolerr_t dragonbas_writefile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+ const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
return basic_writefile(&dragonbas_tokens, partition, filename, fork, sourcef, opts);
}
@@ -3048,13 +3048,13 @@ static const basictokens vzbas_tokens =
};
static imgtoolerr_t vzbas_readfile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *destf)
+ const char *fork, imgtool::stream &destf)
{
return basic_readfile(&vzbas_tokens, partition, filename, fork, destf);
}
static imgtoolerr_t vzbas_writefile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+ const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
return basic_writefile(&vzbas_tokens, partition, filename, fork, sourcef, opts);
}
@@ -3092,13 +3092,13 @@ static const basictokens bml3bas_tokens =
};
static imgtoolerr_t bml3bas_readfile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *destf)
+ const char *fork, imgtool::stream &destf)
{
return basic_readfile(&bml3bas_tokens, partition, filename, fork, destf);
}
static imgtoolerr_t bml3bas_writefile(imgtool::partition *partition, const char *filename,
- const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+ const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
return basic_writefile(&bml3bas_tokens, partition, filename, fork, sourcef, opts);
}
diff --git a/src/tools/imgtool/filteoln.cpp b/src/tools/imgtool/filteoln.cpp
index 762bccec337..cad8e727ec3 100644
--- a/src/tools/imgtool/filteoln.cpp
+++ b/src/tools/imgtool/filteoln.cpp
@@ -16,13 +16,13 @@
-static imgtoolerr_t convert_stream_eolns(imgtool::stream *source, imgtool::stream *dest, const char *eoln)
+static imgtoolerr_t convert_stream_eolns(imgtool::stream &source, imgtool::stream &dest, const char *eoln)
{
size_t len, i, pos;
char buffer[2000];
int hit_cr = FALSE;
- while((len = source->read(buffer, sizeof(buffer))) > 0)
+ while((len = source.read(buffer, sizeof(buffer))) > 0)
{
pos = 0;
@@ -35,8 +35,8 @@ static imgtoolerr_t convert_stream_eolns(imgtool::stream *source, imgtool::strea
if (!hit_cr || (buffer[i] != '\n'))
{
if (i > pos)
- dest->write(buffer + pos, i - pos);
- dest->write(eoln, strlen(eoln));
+ dest.write(buffer + pos, i - pos);
+ dest.write(eoln, strlen(eoln));
}
pos = i + 1;
break;
@@ -45,7 +45,7 @@ static imgtoolerr_t convert_stream_eolns(imgtool::stream *source, imgtool::strea
}
if (i > pos)
- dest->write(buffer + pos, i - pos);
+ dest.write(buffer + pos, i - pos);
}
return IMGTOOLERR_SUCCESS;
@@ -53,7 +53,7 @@ static imgtoolerr_t convert_stream_eolns(imgtool::stream *source, imgtool::strea
-static imgtoolerr_t ascii_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t ascii_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
imgtool::stream *mem_stream;
@@ -65,12 +65,12 @@ static imgtoolerr_t ascii_readfile(imgtool::partition *partition, const char *fi
goto done;
}
- err = partition->read_file(filename, fork, mem_stream, nullptr);
+ err = partition->read_file(filename, fork, *mem_stream, nullptr);
if (err)
goto done;
mem_stream->seek(SEEK_SET, 0);
- err = convert_stream_eolns(mem_stream, destf, EOLN);
+ err = convert_stream_eolns(*mem_stream, destf, EOLN);
if (err)
goto done;
@@ -82,7 +82,7 @@ done:
-static imgtoolerr_t ascii_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t ascii_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t err;
imgtool::stream *mem_stream = nullptr;
@@ -98,12 +98,12 @@ static imgtoolerr_t ascii_writefile(imgtool::partition *partition, const char *f
eoln = partition->get_info_string(IMGTOOLINFO_STR_EOLN);
- err = convert_stream_eolns(sourcef, mem_stream, eoln);
+ err = convert_stream_eolns(sourcef, *mem_stream, eoln);
if (err)
goto done;
mem_stream->seek(SEEK_SET, 0);
- err = partition->write_file(filename, fork, mem_stream, opts, nullptr);
+ err = partition->write_file(filename, fork, *mem_stream, opts, nullptr);
if (err)
goto done;
diff --git a/src/tools/imgtool/iflopimg.cpp b/src/tools/imgtool/iflopimg.cpp
index 85beaaf496c..9b819a7bdb1 100644
--- a/src/tools/imgtool/iflopimg.cpp
+++ b/src/tools/imgtool/iflopimg.cpp
@@ -102,7 +102,7 @@ struct imgtool_floppy_image
-static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool::stream *f, int noclose)
+static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool::stream &f, int noclose)
{
floperr_t ferr;
imgtoolerr_t err;
@@ -117,7 +117,7 @@ static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool:
open = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN);
/* open up the floppy */
- ferr = floppy_open(f, noclose ? &imgtool_noclose_ioprocs : &imgtool_ioprocs,
+ ferr = floppy_open(&f, noclose ? &imgtool_noclose_ioprocs : &imgtool_ioprocs,
"", format, FLOPPY_FLAGS_READWRITE, &fimg->floppy);
if (ferr)
{
@@ -137,14 +137,14 @@ static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool:
-static imgtoolerr_t imgtool_floppy_open(imgtool::image *image, imgtool::stream *f)
+static imgtoolerr_t imgtool_floppy_open(imgtool::image *image, imgtool::stream &f)
{
return imgtool_floppy_open_internal(image, f, FALSE);
}
-static imgtoolerr_t imgtool_floppy_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *opts)
+static imgtoolerr_t imgtool_floppy_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *opts)
{
floperr_t ferr;
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
@@ -161,7 +161,7 @@ static imgtoolerr_t imgtool_floppy_create(imgtool::image *image, imgtool::stream
open = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN);
/* open up the floppy */
- ferr = floppy_create(f, &imgtool_ioprocs, format, opts, &fimg->floppy);
+ ferr = floppy_create(&f, &imgtool_ioprocs, format, opts, &fimg->floppy);
if (ferr)
{
err = imgtool_floppy_error(ferr);
@@ -305,7 +305,7 @@ floppy_image_legacy *imgtool_floppy(imgtool::image *img)
-static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream *f, int direction)
+static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f, int direction)
{
floperr_t err;
floppy_image_legacy *floppy;
@@ -320,11 +320,11 @@ static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool::image
err = floppy_read_sector(floppy, head, track, sector, offset, &buffer[0], length);
if (err)
goto done;
- f->write(&buffer[0], length);
+ f.write(&buffer[0], length);
}
else
{
- f->read(&buffer[0], length);
+ f.read(&buffer[0], length);
err = floppy_write_sector(floppy, head, track, sector, offset, &buffer[0], length, 0); /* TODO: pass ddam argument from imgtool */
if (err)
goto done;
@@ -338,14 +338,14 @@ done:
-imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream *f)
+imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f)
{
return imgtool_floppy_transfer_sector_tofrom_stream(img, head, track, sector, offset, length, f, 1);
}
-imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream *f)
+imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f)
{
return imgtool_floppy_transfer_sector_tofrom_stream(img, head, track, sector, offset, length, f, 0);
}
diff --git a/src/tools/imgtool/iflopimg.h b/src/tools/imgtool/iflopimg.h
index d36607bb449..6981d20960d 100644
--- a/src/tools/imgtool/iflopimg.h
+++ b/src/tools/imgtool/iflopimg.h
@@ -32,8 +32,8 @@ int imgtool_floppy_make_class(int index, imgtool_class *imgclass);
floppy_image_legacy *imgtool_floppy(imgtool::image *img);
imgtoolerr_t imgtool_floppy_error(floperr_t err);
-imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream *f);
-imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream *f);
+imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f);
+imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f);
void *imgtool_floppy_extrabytes(imgtool::image *img);
diff --git a/src/tools/imgtool/imghd.cpp b/src/tools/imgtool/imghd.cpp
index 359db311790..e21c6fbbfdd 100644
--- a/src/tools/imgtool/imghd.cpp
+++ b/src/tools/imgtool/imghd.cpp
@@ -46,7 +46,7 @@ static imgtoolerr_t map_chd_error(chd_error chderr)
Create a MAME HD image
*/
-imgtoolerr_t imghd_create(imgtool::stream *stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen)
+imgtoolerr_t imghd_create(imgtool::stream &stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen)
{
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
chd_file chd;
@@ -63,7 +63,7 @@ imgtoolerr_t imghd_create(imgtool::stream *stream, UINT32 hunksize, UINT32 cylin
hunksize = 1024; /* default value */
/* bail if we are read only */
- if (stream->is_read_only())
+ if (stream.is_read_only())
{
err = IMGTOOLERR_READONLY;
return err;
@@ -73,7 +73,7 @@ imgtoolerr_t imghd_create(imgtool::stream *stream, UINT32 hunksize, UINT32 cylin
const UINT64 logicalbytes = (UINT64)cylinders * heads * sectors * seclen;
/* create the new hard drive */
- rc = chd.create(*stream->core_file(), logicalbytes, hunksize, seclen, compression);
+ rc = chd.create(*stream.core_file(), logicalbytes, hunksize, seclen, compression);
if (rc != CHDERR_NONE)
{
err = map_chd_error(rc);
@@ -81,7 +81,7 @@ imgtoolerr_t imghd_create(imgtool::stream *stream, UINT32 hunksize, UINT32 cylin
}
/* open the new hard drive */
- rc = chd.open(*stream->core_file());
+ rc = chd.open(*stream.core_file());
if (rc != CHDERR_NONE)
{
@@ -125,7 +125,7 @@ imgtoolerr_t imghd_create(imgtool::stream *stream, UINT32 hunksize, UINT32 cylin
Open stream as a MAME HD image
*/
-imgtoolerr_t imghd_open(imgtool::stream *stream, struct mess_hard_disk_file *hard_disk)
+imgtoolerr_t imghd_open(imgtool::stream &stream, struct mess_hard_disk_file *hard_disk)
{
chd_error chderr;
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
@@ -133,7 +133,7 @@ imgtoolerr_t imghd_open(imgtool::stream *stream, struct mess_hard_disk_file *har
hard_disk->hard_disk = nullptr;
hard_disk->chd = nullptr;
- chderr = hard_disk->chd->open(*stream->core_file(), stream->is_read_only());
+ chderr = hard_disk->chd->open(*stream.core_file(), stream.is_read_only());
if (chderr)
{
err = map_chd_error(chderr);
@@ -146,7 +146,7 @@ imgtoolerr_t imghd_open(imgtool::stream *stream, struct mess_hard_disk_file *har
err = IMGTOOLERR_UNEXPECTED;
goto done;
}
- hard_disk->stream = stream;
+ hard_disk->stream = &stream;
done:
if (err)
@@ -218,7 +218,7 @@ const hard_disk_info *imghd_get_header(struct mess_hard_disk_file *disk)
}
-static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions);
+static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
enum
{
@@ -257,7 +257,7 @@ void hd_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo
-static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions)
+static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{
UINT32 blocksize, cylinders, heads, sectors, seclen;
diff --git a/src/tools/imgtool/imghd.h b/src/tools/imgtool/imghd.h
index a929397c9f2..984451c4883 100644
--- a/src/tools/imgtool/imghd.h
+++ b/src/tools/imgtool/imghd.h
@@ -22,10 +22,10 @@ struct mess_hard_disk_file
/* create a new hard disk */
-imgtoolerr_t imghd_create(imgtool::stream *stream, UINT32 blocksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen);
+imgtoolerr_t imghd_create(imgtool::stream &stream, UINT32 blocksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen);
/* opens a hard disk given an Imgtool stream */
-imgtoolerr_t imghd_open(imgtool::stream *stream, struct mess_hard_disk_file *hard_disk);
+imgtoolerr_t imghd_open(imgtool::stream &stream, struct mess_hard_disk_file *hard_disk);
/* close a hard disk */
void imghd_close(struct mess_hard_disk_file *disk);
diff --git a/src/tools/imgtool/imgtool.cpp b/src/tools/imgtool/imgtool.cpp
index 2933df898aa..909d87be21c 100644
--- a/src/tools/imgtool/imgtool.cpp
+++ b/src/tools/imgtool/imgtool.cpp
@@ -573,8 +573,8 @@ imgtool::partition::partition(imgtool::image &image, imgtool_class &imgclass, in
m_next_enum = (imgtoolerr_t(*)(imgtool::directory *, imgtool_dirent *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_NEXT_ENUM);
m_close_enum = (void(*)(imgtool::directory *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CLOSE_ENUM);
m_free_space = (imgtoolerr_t(*)(imgtool::partition *, UINT64 *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_FREE_SPACE);
- m_read_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool::stream *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_READ_FILE);
- m_write_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool::stream *, util::option_resolution *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_WRITE_FILE);
+ m_read_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool::stream &)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_READ_FILE);
+ m_write_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool::stream &, util::option_resolution *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_WRITE_FILE);
m_delete_file = (imgtoolerr_t(*)(imgtool::partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_DELETE_FILE);
m_list_forks = (imgtoolerr_t(*)(imgtool::partition *, const char *, imgtool_forkent *, size_t)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_LIST_FORKS);
m_create_dir = (imgtoolerr_t(*)(imgtool::partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_DIR);
@@ -1507,7 +1507,7 @@ imgtoolerr_t imgtool::partition::suggest_file_filters(const char *path,
imgtoolerr_t err;
int i, j;
char *alloc_path = nullptr;
- imgtoolerr_t (*check_stream)(imgtool::stream *stream, imgtool_suggestion_viability_t *viability);
+ imgtoolerr_t (*check_stream)(imgtool::stream &stream, imgtool_suggestion_viability_t *viability);
size_t position;
// clear out buffer
@@ -1537,11 +1537,11 @@ imgtoolerr_t imgtool::partition::suggest_file_filters(const char *path,
{
if (stream && suggestions[i].filter)
{
- check_stream = (imgtoolerr_t (*)(imgtool::stream *, imgtool_suggestion_viability_t *)) filter_get_info_fct(suggestions[i].filter, FILTINFO_PTR_CHECKSTREAM);
+ check_stream = (imgtoolerr_t (*)(imgtool::stream &, imgtool_suggestion_viability_t *)) filter_get_info_fct(suggestions[i].filter, FILTINFO_PTR_CHECKSTREAM);
if (check_stream)
{
position = stream->tell();
- err = check_stream(stream, &suggestions[i].viability);
+ err = check_stream(*stream, &suggestions[i].viability);
stream->seek(position, SEEK_SET);
if (err)
goto done;
@@ -1697,7 +1697,7 @@ imgtoolerr_t imgtool::partition::get_free_space(UINT64 &sz)
// from a file on a partition with a stream
//-------------------------------------------------
-imgtoolerr_t imgtool::partition::read_file(const char *filename, const char *fork, imgtool::stream *destf, filter_getinfoproc filter)
+imgtoolerr_t imgtool::partition::read_file(const char *filename, const char *fork, imgtool::stream &destf, filter_getinfoproc filter)
{
imgtoolerr_t err;
char *alloc_path = nullptr;
@@ -1758,7 +1758,7 @@ done:
// to a new file on an image with a stream
//-------------------------------------------------
-imgtoolerr_t imgtool::partition::write_file(const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts, filter_getinfoproc filter)
+imgtoolerr_t imgtool::partition::write_file(const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts, filter_getinfoproc filter)
{
imgtoolerr_t err;
char *buf = nullptr;
@@ -1842,7 +1842,7 @@ imgtoolerr_t imgtool::partition::write_file(const char *filename, const char *fo
goto done;
}
- file_size = sourcef->size();
+ file_size = sourcef.size();
if (file_size > free_space)
{
@@ -1921,7 +1921,7 @@ imgtoolerr_t imgtool::partition::get_file(const char *filename, const char *fork
goto done;
}
- err = read_file(new_fname, fork, f, filter);
+ err = read_file(new_fname, fork, *f, filter);
if (err)
goto done;
@@ -1972,7 +1972,7 @@ imgtoolerr_t imgtool::partition::put_file(const char *newfname, const char *fork
f = imgtool::stream::open(source, OSD_FOPEN_READ);
if (f)
- err = write_file(newfname, fork, f, opts, filter);
+ err = write_file(newfname, fork, *f, opts, filter);
else
err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
diff --git a/src/tools/imgtool/imgtool.h b/src/tools/imgtool/imgtool.h
index b22e9681eb9..e13cc8284ae 100644
--- a/src/tools/imgtool/imgtool.h
+++ b/src/tools/imgtool/imgtool.h
@@ -153,8 +153,8 @@ namespace imgtool
imgtoolerr_t get_directory_entry(const char *path, int index, imgtool_dirent &ent);
imgtoolerr_t get_file_size(const char *filename, UINT64 &filesize);
imgtoolerr_t get_free_space(UINT64 &sz);
- imgtoolerr_t read_file(const char *filename, const char *fork, imgtool::stream *destf, filter_getinfoproc filter);
- imgtoolerr_t write_file(const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *resolution, filter_getinfoproc filter);
+ imgtoolerr_t read_file(const char *filename, const char *fork, imgtool::stream &destf, filter_getinfoproc filter);
+ imgtoolerr_t write_file(const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *resolution, filter_getinfoproc filter);
imgtoolerr_t get_file(const char *filename, const char *fork, const char *dest, filter_getinfoproc filter);
imgtoolerr_t put_file(const char *newfname, const char *fork, const char *source, util::option_resolution *opts, filter_getinfoproc filter);
imgtoolerr_t delete_file(const char *fname);
@@ -207,8 +207,8 @@ namespace imgtool
imgtoolerr_t(*m_next_enum) (imgtool::directory *enumeration, imgtool_dirent *ent);
void(*m_close_enum) (imgtool::directory *enumeration);
imgtoolerr_t(*m_free_space) (imgtool::partition *partition, UINT64 *size);
- imgtoolerr_t(*m_read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf);
- imgtoolerr_t(*m_write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts);
+ imgtoolerr_t(*m_read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
+ imgtoolerr_t(*m_write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts);
imgtoolerr_t(*m_delete_file) (imgtool::partition *partition, const char *filename);
imgtoolerr_t(*m_list_forks) (imgtool::partition *partition, const char *path, imgtool_forkent *ents, size_t len);
imgtoolerr_t(*m_create_dir) (imgtool::partition *partition, const char *path);
diff --git a/src/tools/imgtool/library.h b/src/tools/imgtool/library.h
index 0452d7e7813..7403dc59db3 100644
--- a/src/tools/imgtool/library.h
+++ b/src/tools/imgtool/library.h
@@ -48,9 +48,9 @@ union filterinfo
void * f; /* generic function pointers */
const char *s; /* generic strings */
- imgtoolerr_t (*read_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf);
- imgtoolerr_t (*write_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts);
- imgtoolerr_t (*check_stream)(imgtool::stream *stream, imgtool_suggestion_viability_t *viability);
+ imgtoolerr_t (*read_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
+ imgtoolerr_t (*write_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts);
+ imgtoolerr_t (*check_stream)(imgtool::stream &stream, imgtool_suggestion_viability_t *viability);
};
typedef void (*filter_getinfoproc)(UINT32 state, union filterinfo *info);
@@ -254,9 +254,9 @@ union imgtoolinfo
void * f; /* generic function pointers */
char * s; /* generic strings */
- imgtoolerr_t (*open) (imgtool::image *image, imgtool::stream *stream);
+ imgtoolerr_t (*open) (imgtool::image *image, imgtool::stream &stream);
void (*close) (imgtool::image *image);
- imgtoolerr_t (*create) (imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts);
+ imgtoolerr_t (*create) (imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts);
imgtoolerr_t (*create_partition) (imgtool::image *image, UINT64 first_block, UINT64 block_count);
void (*info) (imgtool::image *image, char *string, size_t len);
imgtoolerr_t (*begin_enum) (imgtool::directory *enumeration, const char *path);
@@ -264,8 +264,8 @@ union imgtoolinfo
void (*close_enum) (imgtool::directory *enumeration);
imgtoolerr_t (*open_partition) (imgtool::partition *partition, UINT64 first_block, UINT64 block_count);
imgtoolerr_t (*free_space) (imgtool::partition *partition, UINT64 *size);
- imgtoolerr_t (*read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf);
- imgtoolerr_t (*write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts);
+ imgtoolerr_t (*read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
+ imgtoolerr_t (*write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts);
imgtoolerr_t (*delete_file) (imgtool::partition *partition, const char *filename);
imgtoolerr_t (*list_forks) (imgtool::partition *partition, const char *path, imgtool_forkent *ents, size_t len);
imgtoolerr_t (*create_dir) (imgtool::partition *partition, const char *path);
diff --git a/src/tools/imgtool/modules/amiga.cpp b/src/tools/imgtool/modules/amiga.cpp
index 13e2fb03b09..3efd76e9117 100644
--- a/src/tools/imgtool/modules/amiga.cpp
+++ b/src/tools/imgtool/modules/amiga.cpp
@@ -1567,7 +1567,7 @@ static imgtoolerr_t checkdir(imgtool::image *img, const char *path, int parent)
/* Writes the file data from the specified block into the stream */
-static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int size, imgtool::stream *destf)
+static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int size, imgtool::stream &destf)
{
imgtoolerr_t ret;
UINT8 buffer[BSIZE];
@@ -1606,7 +1606,7 @@ static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int si
}
/* Write data to stream */
- if (destf->write(buffer, size) != size)
+ if (destf.write(buffer, size) != size)
{
return IMGTOOLERR_WRITEERROR;
}
@@ -1615,7 +1615,7 @@ static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int si
}
-static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool::stream *destf, int write)
+static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool::stream *destf, bool write)
{
int i, blocksize = is_ffs(img) ? BSIZE : BSIZE-24;
imgtoolerr_t ret;
@@ -1627,7 +1627,7 @@ static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *f
if (write)
{
- ret = write_file_block_data(img, ptr[i], bytes_left, destf);
+ ret = write_file_block_data(img, ptr[i], bytes_left, *destf);
if (ret) return ret;
}
else
@@ -1646,16 +1646,16 @@ static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *f
}
-static imgtoolerr_t write_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool::stream *destf)
+static imgtoolerr_t write_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool::stream &destf)
{
- return walk_data_block_ptr(img, ptr, filesize, destf, TRUE);
+ return walk_data_block_ptr(img, ptr, filesize, &destf, true);
}
/* Marks all blocks pointed to by the data block pointers as free */
static imgtoolerr_t clear_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize)
{
- return walk_data_block_ptr(img, ptr, filesize, NULL, FALSE);
+ return walk_data_block_ptr(img, ptr, filesize, nullptr, false);
}
@@ -1742,12 +1742,12 @@ static imgtoolerr_t update_disk_alteration_date(imgtool::image *img)
*****************************************************************************/
-static imgtoolerr_t amiga_image_open(imgtool::image *img, imgtool::stream *stream)
+static imgtoolerr_t amiga_image_open(imgtool::image *img, imgtool::stream &stream)
{
amiga_floppy *f = (amiga_floppy *) img->extra_bytes();
- UINT64 size = stream->size();
+ UINT64 size = stream.size();
- f->stream = stream;
+ f->stream = &stream;
f->sectors = size/BSIZE/80/2;
if (f->sectors != 11 && f->sectors != 22)
@@ -2079,7 +2079,7 @@ static imgtoolerr_t amiga_image_freespace(imgtool::partition *partition, UINT64
}
-static imgtoolerr_t amiga_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t amiga_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtool::image *img = &partition->image();
imgtoolerr_t ret;
@@ -2105,7 +2105,7 @@ static imgtoolerr_t amiga_image_readfile(imgtool::partition *partition, const ch
if (filesize == 0) return IMGTOOLERR_SUCCESS;
/* Phase 2: Follow file extension blocks */
- ret = write_file_ext_data(img, file.extension, &filesize, destf);
+ ret = write_file_ext_data(img, file.extension, &filesize, &destf);
if (ret) return ret;
return IMGTOOLERR_SUCCESS;
@@ -2189,13 +2189,13 @@ static imgtoolerr_t amiga_image_deletefile(imgtool::partition *partition, const
}
-static imgtoolerr_t amiga_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t amiga_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
return IMGTOOLERR_UNIMPLEMENTED;
}
-static imgtoolerr_t amiga_image_create(imgtool::image *img, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t amiga_image_create(imgtool::image *img, imgtool::stream &stream, util::option_resolution *opts)
{
amiga_floppy *f = (amiga_floppy *) img->extra_bytes();
const std::string &dskname = opts->lookup_string('N');
@@ -2206,7 +2206,7 @@ static imgtoolerr_t amiga_image_create(imgtool::image *img, imgtool::stream *str
time_t now;
int blocks;
- f->stream = stream;
+ f->stream = &stream;
switch (opts->lookup_int('S'))
{
diff --git a/src/tools/imgtool/modules/bml3.cpp b/src/tools/imgtool/modules/bml3.cpp
index ef68e780e79..62f6940dea3 100644
--- a/src/tools/imgtool/modules/bml3.cpp
+++ b/src/tools/imgtool/modules/bml3.cpp
@@ -283,7 +283,7 @@ static void granule_location(imgtool::image *image, UINT8 granule, UINT8 *head,
-static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream *f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool::stream *))
+static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool::stream &))
{
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
UINT8 head, track, sector;
@@ -294,14 +294,14 @@ static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int len
}
-static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream *destf)
+static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &destf)
{
return transfer_granule(img, granule, length, destf, imgtool_floppy_read_sector_to_stream);
}
-static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream *sourcef)
+static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &sourcef)
{
return transfer_granule(img, granule, length, sourcef, imgtool_floppy_write_sector_from_stream);
}
@@ -444,7 +444,7 @@ static imgtoolerr_t process_bml3_file(struct bml3_dirent *ent, imgtool::image *i
for (int c = 0; c < granule_list.granule_count; c++) {
if (granule_size >= remaining_size)
granule_size = remaining_size;
- transfer_from_granule(img, granule_list.granules[c], granule_size, destf);
+ transfer_from_granule(img, granule_list.granules[c], granule_size, *destf);
remaining_size -= granule_size;
}
}
@@ -498,7 +498,7 @@ static imgtoolerr_t prepare_dirent(UINT8 variant, struct bml3_dirent *ent, const
-static imgtoolerr_t bml3_diskimage_open(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t bml3_diskimage_open(imgtool::image *image, imgtool::stream &stream)
{
// imgtoolerr_t err;
floperr_t ferr;
@@ -586,7 +586,7 @@ eof:
else
{
/* Not the end of file */
- err = process_bml3_file(&rsent, image, NULL, &filesize);
+ err = process_bml3_file(&rsent, image, nullptr, &filesize);
if (err)
return err;
@@ -673,18 +673,18 @@ static imgtoolerr_t delete_entry(imgtool::image *img, struct bml3_dirent *ent, i
-static imgtoolerr_t bml3_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t bml3_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
struct bml3_dirent ent;
size_t size;
imgtool::image *img = &partition->image();
- err = lookup_bml3_file(img, fname, &ent, NULL);
+ err = lookup_bml3_file(img, fname, &ent, nullptr);
if (err)
return err;
- err = process_bml3_file(&ent, img, destf, &size);
+ err = process_bml3_file(&ent, img, &destf, &size);
if (err)
return err;
@@ -696,7 +696,7 @@ static imgtoolerr_t bml3_diskimage_readfile(imgtool::partition *partition, const
-static imgtoolerr_t bml3_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions)
+static imgtoolerr_t bml3_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{
floperr_t ferr;
imgtoolerr_t err;
@@ -724,7 +724,7 @@ static imgtoolerr_t bml3_diskimage_writefile(imgtool::partition *partition, cons
return err;
/* is there enough space? */
- sz = read_sz = sourcef->size();
+ sz = read_sz = sourcef.size();
if (info->variant == 0) {
// also need to write EOF
sz++;
diff --git a/src/tools/imgtool/modules/concept.cpp b/src/tools/imgtool/modules/concept.cpp
index 3644e19fef2..6a285903a7f 100644
--- a/src/tools/imgtool/modules/concept.cpp
+++ b/src/tools/imgtool/modules/concept.cpp
@@ -126,14 +126,14 @@ struct concept_iterator
};
-static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool::stream *f);
+static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool::stream &f);
static void concept_image_exit(imgtool::image *img);
static void concept_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t concept_image_beginenum(imgtool::directory *enumeration, const char *path);
static imgtoolerr_t concept_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent);
static void concept_image_closeenum(imgtool::directory *enumeration);
static imgtoolerr_t concept_image_freespace(imgtool::partition *partition, UINT64 *size);
-static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf);
+static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
#if 0
static imgtoolerr_t concept_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions);
static imgtoolerr_t concept_image_deletefile(imgtool::partition *partition, const char *filename);
@@ -180,16 +180,16 @@ void concept_get_info(const imgtool_class *imgclass, UINT32 state, union imgtool
Return non-zero on error
*/
-static int read_physical_record(imgtool::stream *file_handle, int secnum, void *dest)
+static int read_physical_record(imgtool::stream &file_handle, int secnum, void *dest)
{
int reply;
/* seek to sector */
- reply = file_handle->seek(secnum*512, SEEK_SET);
+ reply = file_handle.seek(secnum*512, SEEK_SET);
if (reply)
return 1;
/* read it */
- reply = file_handle->read(dest, 512);
+ reply = file_handle.read(dest, 512);
if (reply != 512)
return 1;
@@ -260,14 +260,14 @@ static int get_catalog_entry(concept_image *image, const unsigned char *filename
/*
Open a file as a concept_image.
*/
-static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool::stream *f)
+static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool::stream &f)
{
concept_image *image = (concept_image *) img->extra_bytes();
int reply;
int i;
unsigned totphysrecs;
- image->file_handle = f;
+ image->file_handle = &f;
/* read device directory */
for (i=0; i<4; i++)
@@ -426,7 +426,7 @@ static imgtoolerr_t concept_image_freespace(imgtool::partition *partition, UINT6
/*
Extract a file from a concept_image.
*/
-static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtool::image *img = &partition->image();
concept_image *image = (concept_image *) img->extra_bytes();
@@ -449,10 +449,10 @@ static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const
i < get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.file_dir[catalog_index].next_block);
i++)
{
- if (read_physical_record(image->file_handle, i, buf))
+ if (read_physical_record(*image->file_handle, i, buf))
return IMGTOOLERR_READERROR;
- if (destf->write(buf, 512) != 512)
+ if (destf.write(buf, 512) != 512)
return IMGTOOLERR_WRITEERROR;
}
diff --git a/src/tools/imgtool/modules/cybiko.cpp b/src/tools/imgtool/modules/cybiko.cpp
index 489606328eb..f6e213fe6a2 100644
--- a/src/tools/imgtool/modules/cybiko.cpp
+++ b/src/tools/imgtool/modules/cybiko.cpp
@@ -252,32 +252,32 @@ static int cfs_file_find( cybiko_file_system *cfs, const char *filename, UINT16
return FALSE;
}
-static int cfs_verify( cybiko_file_system *cfs)
+static int cfs_verify(cybiko_file_system &cfs)
{
UINT8 buffer[MAX_PAGE_SIZE];
int i, block_type;
- for (i=0;i<cfs->page_count;i++)
+ for (i = 0; i < cfs.page_count; i++)
{
- if (!cfs_page_read( cfs, buffer, i)) return FALSE;
- if (!cfs_page_to_block( cfs, i, &block_type, NULL)) return FALSE;
- if (!page_buffer_verify( buffer, cfs->page_size, block_type)) return FALSE;
+ if (!cfs_page_read(&cfs, buffer, i)) return FALSE;
+ if (!cfs_page_to_block(&cfs, i, &block_type, NULL)) return FALSE;
+ if (!page_buffer_verify(buffer, cfs.page_size, block_type)) return FALSE;
}
return TRUE;
}
-static int cfs_init( cybiko_file_system *cfs, imgtool::stream *stream, int flash_type)
+static int cfs_init(cybiko_file_system &cfs, imgtool::stream &stream, int flash_type)
{
- cfs->stream = stream;
+ cfs.stream = &stream;
switch (flash_type)
{
- case FLASH_TYPE_AT45DB041 : cfs->page_count = 2048; cfs->page_size = 264; break;
- case FLASH_TYPE_AT45DB081 : cfs->page_count = 4096; cfs->page_size = 264; break;
- case FLASH_TYPE_AT45DB161 : cfs->page_count = 4096; cfs->page_size = 528; break;
+ case FLASH_TYPE_AT45DB041 : cfs.page_count = 2048; cfs.page_size = 264; break;
+ case FLASH_TYPE_AT45DB081 : cfs.page_count = 4096; cfs.page_size = 264; break;
+ case FLASH_TYPE_AT45DB161 : cfs.page_count = 4096; cfs.page_size = 528; break;
default : return FALSE;
}
- cfs->block_count_boot = 5;
- cfs->block_count_file = cfs->page_count - cfs->block_count_boot;
- cfs->write_count = 0;
+ cfs.block_count_boot = 5;
+ cfs.block_count_file = cfs.page_count - cfs.block_count_boot;
+ cfs.write_count = 0;
return TRUE;
}
@@ -345,15 +345,15 @@ static int flash_option_to_flash_type( int option)
}
}
-static imgtoolerr_t cybiko_image_open( imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t cybiko_image_open(imgtool::image *image, imgtool::stream &stream)
{
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
int flash_type;
// init
- flash_type = flash_size_to_flash_type( stream->size());
- if (!cfs_init( cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE;
+ flash_type = flash_size_to_flash_type(stream.size());
+ if (!cfs_init(*cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE;
// verify
- if (!cfs_verify( cfs)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_verify(*cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok
return IMGTOOLERR_SUCCESS;
}
@@ -364,15 +364,15 @@ static void cybiko_image_close( imgtool::image *image)
delete cfs->stream;
}
-static imgtoolerr_t cybiko_image_create( imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t cybiko_image_create( imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
int flash_type;
// init
flash_type = flash_option_to_flash_type(opts->lookup_int('F'));
- if (!cfs_init( cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_init(*cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE;
// format
- if (!cfs_format( cfs)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_format(cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok
return IMGTOOLERR_SUCCESS;
}
@@ -423,7 +423,7 @@ static void cybiko_image_close_enum( imgtool::directory *enumeration)
// nothing
}
-static imgtoolerr_t cybiko_image_free_space( imgtool::partition *partition, UINT64 *size)
+static imgtoolerr_t cybiko_image_free_space(imgtool::partition *partition, UINT64 *size)
{
imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@@ -431,7 +431,7 @@ static imgtoolerr_t cybiko_image_free_space( imgtool::partition *partition, UINT
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t cybiko_image_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@@ -449,7 +449,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
if (!cfs_block_read( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_READERROR;
if (BLOCK_USED(buffer) && (BLOCK_FILE_ID(buffer) == file_id) && (BLOCK_PART_ID(buffer) == part_id))
{
- destf->write(buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]);
+ destf.write(buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]);
part_id++;
}
}
@@ -458,7 +458,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t cybiko_image_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@@ -468,22 +468,22 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
cfs_file file;
int i;
// find file
- if (!cfs_file_find( cfs, filename, &file_id)) file_id = INVALID_FILE_ID;
+ if (!cfs_file_find(cfs, filename, &file_id)) file_id = INVALID_FILE_ID;
// check free space
free_blocks = cfs_calc_free_blocks( cfs);
if (file_id != INVALID_FILE_ID)
{
- if (!cfs_file_info( cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED;
+ if (!cfs_file_info(cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED;
free_blocks += file.blocks;
}
- if (cfs_calc_free_space( cfs, free_blocks) < sourcef->size()) return IMGTOOLERR_NOSPACE;
+ if (cfs_calc_free_space(cfs, free_blocks) < sourcef.size()) return IMGTOOLERR_NOSPACE;
// delete file
if (file_id != INVALID_FILE_ID)
{
if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
}
// create/write destination file
- bytes_left = sourcef->size();
+ bytes_left = sourcef.size();
i = 0;
while ((bytes_left > 0) && (i < cfs->block_count_file))
{
@@ -500,13 +500,13 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
if (part_id == 0)
{
buffer[6] = 0;
- strcpy( BLOCK_FILENAME(buffer), filename);
+ strcpy(BLOCK_FILENAME(buffer), filename);
buffer_write_32_be( buffer + 6 + FILE_HEADER_SIZE - 4, time_setup( time( NULL)));
- sourcef->read(buffer + 6 + FILE_HEADER_SIZE, buffer[1]);
+ sourcef.read(buffer + 6 + FILE_HEADER_SIZE, buffer[1]);
}
else
{
- sourcef->read(buffer + 6, buffer[1]);
+ sourcef.read(buffer + 6, buffer[1]);
}
if (!cfs_block_write( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_WRITEERROR;
bytes_left -= buffer[1];
diff --git a/src/tools/imgtool/modules/cybikoxt.cpp b/src/tools/imgtool/modules/cybikoxt.cpp
index cd40320f547..6c43472011f 100644
--- a/src/tools/imgtool/modules/cybikoxt.cpp
+++ b/src/tools/imgtool/modules/cybikoxt.cpp
@@ -247,31 +247,31 @@ static int cfs_file_find( cybiko_file_system *cfs, const char *filename, UINT16
return FALSE;
}
-static int cfs_verify( cybiko_file_system *cfs)
+static bool cfs_verify(cybiko_file_system &cfs)
{
UINT8 buffer[MAX_PAGE_SIZE];
int i, block_type;
- for (i=0;i<cfs->page_count;i++)
+ for (i = 0; i < cfs.page_count; i++)
{
- if (!cfs_page_read( cfs, buffer, i)) return FALSE;
- if (!cfs_page_to_block( cfs, i, &block_type, NULL)) return FALSE;
- if (!page_buffer_verify( buffer, cfs->page_size, block_type)) return FALSE;
+ if (!cfs_page_read(&cfs, buffer, i)) return false;
+ if (!cfs_page_to_block(&cfs, i, &block_type, NULL)) return false;
+ if (!page_buffer_verify(buffer, cfs.page_size, block_type)) return false;
}
- return TRUE;
+ return true;
}
-static int cfs_init( cybiko_file_system *cfs, imgtool::stream *stream)
+static bool cfs_init(cybiko_file_system &cfs, imgtool::stream &stream)
{
- cfs->stream = stream;
- cfs->page_count = 2005;
- cfs->page_size = 258;
- cfs->block_count_boot = 5;
- cfs->block_count_file = cfs->page_count - cfs->block_count_boot;
- cfs->write_count = 0;
- return TRUE;
+ cfs.stream = &stream;
+ cfs.page_count = 2005;
+ cfs.page_size = 258;
+ cfs.block_count_boot = 5;
+ cfs.block_count_file = cfs.page_count - cfs.block_count_boot;
+ cfs.write_count = 0;
+ return true;
}
-static int cfs_format( cybiko_file_system *cfs)
+static int cfs_format(cybiko_file_system *cfs)
{
UINT8 buffer[MAX_PAGE_SIZE];
int i;
@@ -319,30 +319,30 @@ static UINT32 cfs_calc_free_space( cybiko_file_system *cfs, UINT16 blocks)
return free_space;
}
-static imgtoolerr_t cybiko_image_open( imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t cybiko_image_open(imgtool::image *image, imgtool::stream &stream)
{
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
// init
- if (!cfs_init( cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_init(*cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE;
// verify
- if (!cfs_verify( cfs)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_verify(*cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok
return IMGTOOLERR_SUCCESS;
}
-static void cybiko_image_close( imgtool::image *image)
+static void cybiko_image_close(imgtool::image *image)
{
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
delete cfs->stream;
}
-static imgtoolerr_t cybiko_image_create( imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t cybiko_image_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
// init
- if (!cfs_init( cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_init(*cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE;
// format
- if (!cfs_format( cfs)) return IMGTOOLERR_CORRUPTIMAGE;
+ if (!cfs_format(cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok
return IMGTOOLERR_SUCCESS;
}
@@ -401,7 +401,7 @@ static imgtoolerr_t cybiko_image_free_space( imgtool::partition *partition, UINT
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t cybiko_image_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@@ -421,7 +421,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
if (!cfs_block_read( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_READERROR;
if (BLOCK_USED(buffer) && (BLOCK_FILE_ID(buffer) == file_id) && (BLOCK_PART_ID(buffer) == part_id))
{
- destf->write(buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]);
+ destf.write(buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]);
part_id++;
}
}
@@ -430,7 +430,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t cybiko_image_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@@ -444,20 +444,20 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
// find file
if (!cfs_file_find( cfs, filename, &file_id)) file_id = INVALID_FILE_ID;
// check free space
- free_blocks = cfs_calc_free_blocks( cfs);
+ free_blocks = cfs_calc_free_blocks(cfs);
if (file_id != INVALID_FILE_ID)
{
- if (!cfs_file_info( cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED;
+ if (!cfs_file_info(cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED;
free_blocks += file.blocks;
}
- if (cfs_calc_free_space( cfs, free_blocks) < sourcef->size()) return IMGTOOLERR_NOSPACE;
+ if (cfs_calc_free_space(cfs, free_blocks) < sourcef.size()) return IMGTOOLERR_NOSPACE;
// delete file
if (file_id != INVALID_FILE_ID)
{
- if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
+ if (!cfs_file_delete(cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
}
// create/write destination file
- bytes_left = sourcef->size();
+ bytes_left = sourcef.size();
i = 0;
while (i < cfs->block_count_file)
{
@@ -474,13 +474,13 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
if (part_id == 0)
{
buffer[6] = 0x20;
- strcpy( BLOCK_FILENAME(buffer), filename);
+ strcpy(BLOCK_FILENAME(buffer), filename);
buffer_write_32_be( buffer + 6 + FILE_HEADER_SIZE - 4, time_setup( time( NULL)));
- sourcef->read(buffer + 6 + FILE_HEADER_SIZE, buffer[1]);
+ sourcef.read(buffer + 6 + FILE_HEADER_SIZE, buffer[1]);
}
else
{
- sourcef->read(buffer + 6, buffer[1]);
+ sourcef.read(buffer + 6, buffer[1]);
}
if (!cfs_block_write( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_WRITEERROR;
bytes_left -= buffer[1];
@@ -499,11 +499,11 @@ static imgtoolerr_t cybiko_image_delete_file( imgtool::partition *partition, con
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
UINT16 file_id;
// check filename
- if (strlen( filename) > 58) return IMGTOOLERR_BADFILENAME;
+ if (strlen(filename) > 58) return IMGTOOLERR_BADFILENAME;
// find file
- if (!cfs_file_find( cfs, filename, &file_id)) return IMGTOOLERR_FILENOTFOUND;
+ if (!cfs_file_find(cfs, filename, &file_id)) return IMGTOOLERR_FILENOTFOUND;
// delete file
- if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
+ if (!cfs_file_delete(cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
// ok
return IMGTOOLERR_SUCCESS;
}
diff --git a/src/tools/imgtool/modules/fat.cpp b/src/tools/imgtool/modules/fat.cpp
index f14b4807365..2fcdf3f5306 100644
--- a/src/tools/imgtool/modules/fat.cpp
+++ b/src/tools/imgtool/modules/fat.cpp
@@ -1850,7 +1850,7 @@ static imgtoolerr_t fat_partition_nextenum(imgtool::directory *enumeration, imgt
-static imgtoolerr_t fat_read_bootblock(imgtool::partition *partition, imgtool::stream *stream)
+static imgtoolerr_t fat_read_bootblock(imgtool::partition *partition, imgtool::stream &stream)
{
imgtoolerr_t err;
UINT8 block[FAT_SECLEN];
@@ -1859,21 +1859,21 @@ static imgtoolerr_t fat_read_bootblock(imgtool::partition *partition, imgtool::s
if (err)
return err;
- stream->write(block, sizeof(block));
+ stream.write(block, sizeof(block));
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t fat_write_bootblock(imgtool::partition *partition, imgtool::stream *stream)
+static imgtoolerr_t fat_write_bootblock(imgtool::partition *partition, imgtool::stream &stream)
{
imgtoolerr_t err;
UINT8 block[FAT_SECLEN];
UINT8 new_block[FAT_SECLEN];
- if (stream->size() != sizeof(new_block))
+ if (stream.size() != sizeof(new_block))
return IMGTOOLERR_UNEXPECTED;
- stream->read(new_block, sizeof(new_block));
+ stream.read(new_block, sizeof(new_block));
if (new_block[510] != 0x55)
return IMGTOOLERR_UNEXPECTED;
@@ -1899,7 +1899,7 @@ static imgtoolerr_t fat_write_bootblock(imgtool::partition *partition, imgtool::
-static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
fat_file file;
@@ -1923,7 +1923,7 @@ static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const
if (err)
return err;
- destf->write(buffer, bytes_read);
+ destf.write(buffer, bytes_read);
}
while(bytes_read > 0);
return IMGTOOLERR_SUCCESS;
@@ -1931,7 +1931,7 @@ static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const
-static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t err;
fat_file file;
@@ -1949,7 +1949,7 @@ static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const
if (file.directory)
return IMGTOOLERR_FILENOTFOUND;
- bytes_left = (UINT32) sourcef->size();
+ bytes_left = (UINT32) sourcef.size();
err = fat_set_file_size(partition, &file, bytes_left);
if (err)
@@ -1958,7 +1958,7 @@ static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const
while(bytes_left > 0)
{
len = (std::min<size_t>)(bytes_left, sizeof(buffer));
- sourcef->read(buffer, len);
+ sourcef.read(buffer, len);
err = fat_write_file(partition, &file, buffer, len, NULL);
if (err)
diff --git a/src/tools/imgtool/modules/hp48.cpp b/src/tools/imgtool/modules/hp48.cpp
index 12b8236d86c..1556e1ffb74 100644
--- a/src/tools/imgtool/modules/hp48.cpp
+++ b/src/tools/imgtool/modules/hp48.cpp
@@ -327,36 +327,36 @@ static UINT16 crc(UINT8* data, int len)
*****************************************************************************/
-static imgtoolerr_t hp48_open(imgtool::image *img, imgtool::stream *stream)
+static imgtoolerr_t hp48_open(imgtool::image *img, imgtool::stream &stream)
{
hp48_card* c = (hp48_card*) img->extra_bytes();
- int size = stream->size();
+ int size = stream.size();
- /* check that size is a power of 2 between 32 KB and 4 MG */
- if ( (size < 32 * 1024) ||
- (size > 4 * 1024 * 1024) ||
- (size & (size-1)) )
- {
- return IMGTOOLERR_CORRUPTIMAGE;
- }
+ /* check that size is a power of 2 between 32 KB and 4 MG */
+ if ( (size < 32 * 1024) ||
+ (size > 4 * 1024 * 1024) ||
+ (size & (size-1)) )
+ {
+ return IMGTOOLERR_CORRUPTIMAGE;
+ }
- /* store info */
- c->stream = stream;
+ /* store info */
+ c->stream = &stream;
c->modified = 0;
- c->size = size;
- c->data = (UINT8*) malloc( 2 * size );
- if ( !c->data )
- {
- return IMGTOOLERR_READERROR;
- }
+ c->size = size;
+ c->data = (UINT8*) malloc( 2 * size );
+ if ( !c->data )
+ {
+ return IMGTOOLERR_READERROR;
+ }
- /* fully load image */
- stream->seek(0, SEEK_SET);
- if ( stream->read(c->data, size) < size )
- {
- return IMGTOOLERR_READERROR;
- }
- unpack( c->data, c->data, 2 * size );
+ /* fully load image */
+ stream.seek(0, SEEK_SET);
+ if (stream.read(c->data, size) < size)
+ {
+ return IMGTOOLERR_READERROR;
+ }
+ unpack( c->data, c->data, 2 * size );
return IMGTOOLERR_SUCCESS;
}
@@ -364,25 +364,25 @@ static imgtoolerr_t hp48_open(imgtool::image *img, imgtool::stream *stream)
static imgtoolerr_t hp48_create(imgtool::image* img,
- imgtool::stream *stream,
+ imgtool::stream &stream,
util::option_resolution *opts)
{
hp48_card* c = (hp48_card*) img->extra_bytes();
int size;
- size = opts->lookup_int('S');
+ size = opts->lookup_int('S');
- c->stream = stream;
- c->modified = 1;
- c->size = size * 1024;
- c->data = (UINT8*) malloc( 2 * c->size );
- if ( !c->data )
- {
- return IMGTOOLERR_READERROR;
- }
+ c->stream = &stream;
+ c->modified = 1;
+ c->size = size * 1024;
+ c->data = (UINT8*) malloc( 2 * c->size );
+ if ( !c->data )
+ {
+ return IMGTOOLERR_READERROR;
+ }
- /* zeroing the image seems fine */
- memset( c->data, 0, 2 * c->size );
+ /* zeroing the image seems fine */
+ memset( c->data, 0, 2 * c->size );
return IMGTOOLERR_SUCCESS;
}
@@ -542,7 +542,7 @@ static imgtoolerr_t hp48_freespace(imgtool::partition *part, UINT64 *size)
static imgtoolerr_t hp48_readfile(imgtool::partition *part,
const char *filename,
const char *fork,
- imgtool::stream *destf)
+ imgtool::stream &destf)
{
//imgtool::image* img = &part->image();
//hp48_card* c = (hp48_card*) img->extra_bytes();
@@ -566,7 +566,7 @@ static imgtoolerr_t hp48_readfile(imgtool::partition *part,
size -= 10;
/* save header */
- destf->write(hp48_prefix, 8);
+ destf.write(hp48_prefix, 8);
/* save contents to host file */
int bytesize = (size + 1) / 2;
@@ -576,7 +576,7 @@ static imgtoolerr_t hp48_readfile(imgtool::partition *part,
return IMGTOOLERR_FILENOTFOUND;
}
pack( buf, p->data + start, size );
- destf->write(buf, bytesize);
+ destf.write(buf, bytesize);
free( buf );
return IMGTOOLERR_SUCCESS;
@@ -613,7 +613,7 @@ static imgtoolerr_t hp48_deletefile(imgtool::partition *part,
static imgtoolerr_t hp48_writefile(imgtool::partition *part,
const char *filename,
const char *fork,
- imgtool::stream *sourcef,
+ imgtool::stream &sourcef,
util::option_resolution *opts)
{
imgtool::image* img = &part->image();
@@ -622,7 +622,7 @@ static imgtoolerr_t hp48_writefile(imgtool::partition *part,
/* check header */
char head[8];
- sourcef->read(head, 8);
+ sourcef.read(head, 8);
if ( memcmp( head, hp48_prefix, 7) )
{
return IMGTOOLERR_READERROR;
@@ -640,7 +640,7 @@ static imgtoolerr_t hp48_writefile(imgtool::partition *part,
if ( len > 255 ) len = 255;
/* check size */
- int filesize = sourcef->size() - 8;
+ int filesize = sourcef.size() - 8;
if ( pos + 2*filesize + 24 + 2*len > 2 * p->size )
{
return IMGTOOLERR_NOSPACE;
@@ -649,7 +649,7 @@ static imgtoolerr_t hp48_writefile(imgtool::partition *part,
/* load file */
UINT8* buf = (UINT8*) malloc( filesize );
if ( !buf ) return IMGTOOLERR_NOSPACE;
- sourcef->read(buf, filesize);
+ sourcef.read(buf, filesize);
/* store backup object */
int org = pos;
diff --git a/src/tools/imgtool/modules/hp9845_tape.cpp b/src/tools/imgtool/modules/hp9845_tape.cpp
index bc2925d19f5..23eb78afe30 100644
--- a/src/tools/imgtool/modules/hp9845_tape.cpp
+++ b/src/tools/imgtool/modules/hp9845_tape.cpp
@@ -1042,22 +1042,22 @@ static tape_image_t& get_tape_image(tape_state_t& ts)
/********************************************************************************
* Imgtool functions
********************************************************************************/
-static imgtoolerr_t hp9845_tape_open(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t hp9845_tape_open(imgtool::image *image, imgtool::stream &stream)
{
tape_state_t& state = get_tape_state(image);
- state.stream = stream;
+ state.stream = &stream;
tape_image_t& tape_image = get_tape_image(state);
- return tape_image.load_from_file(stream);
+ return tape_image.load_from_file(&stream);
}
-static imgtoolerr_t hp9845_tape_create(imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t hp9845_tape_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
tape_state_t& state = get_tape_state(image);
- state.stream = stream;
+ state.stream = &stream;
tape_image_t& tape_image = get_tape_image(state);
@@ -1125,7 +1125,7 @@ static imgtoolerr_t hp9845_tape_free_space(imgtool::partition *partition, UINT64
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t hp9845_tape_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t hp9845_tape_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
tape_state_t& state = get_tape_state(&partition->image());
tape_image_t& tape_image = get_tape_image(state);
@@ -1153,13 +1153,13 @@ static imgtoolerr_t hp9845_tape_read_file(imgtool::partition *partition, const c
tape_image_t::tape_word_to_bytes(buff_w[ i ], buff_b[ i * 2 ], buff_b[ i * 2 + 1 ]);
}
- destf->write(buff_b , SECTOR_LEN);
+ destf.write(buff_b , SECTOR_LEN);
}
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
tape_state_t& state = get_tape_state(&partition->image());
tape_image_t& tape_image = get_tape_image(state);
@@ -1171,7 +1171,7 @@ static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const
tape_image.delete_dir_entry(idx);
}
- unsigned blocks = (unsigned)((sourcef->size() + SECTOR_LEN - 1) / SECTOR_LEN);
+ unsigned blocks = (unsigned)((sourcef.size() + SECTOR_LEN - 1) / SECTOR_LEN);
if (!blocks) {
fprintf(stderr , "Null file, not writing..\n");
@@ -1199,7 +1199,7 @@ static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const
memset(&buff_b[ 0 ] , 0 , sizeof(buff_b));
- if (sourcef->read(buff_b , SECTOR_LEN) != SECTOR_LEN && i != (blocks - 1)) {
+ if (sourcef.read(buff_b , SECTOR_LEN) != SECTOR_LEN && i != (blocks - 1)) {
return IMGTOOLERR_READERROR;
}
for (unsigned j = 0; j < WORDS_PER_SECTOR; j++) {
@@ -1354,22 +1354,22 @@ void hp9845_tape_get_info(const imgtool_class *imgclass, UINT32 state, union img
/********************************************************************************
* Filter functions
********************************************************************************/
-static unsigned len_to_eor(imgtool::stream *inp)
+static unsigned len_to_eor(imgtool::stream &inp)
{
- return SECTOR_LEN - (unsigned)(inp->tell() % SECTOR_LEN);
+ return SECTOR_LEN - (unsigned)(inp.tell() % SECTOR_LEN);
}
-static bool get_record_part(imgtool::stream *inp , void *buf , unsigned len)
+static bool get_record_part(imgtool::stream &inp , void *buf , unsigned len)
{
// Reading must never cross sector boundary
if (len > len_to_eor(inp)) {
return false;
}
- return inp->read(buf, len) == len;
+ return inp.read(buf, len) == len;
}
-static bool dump_string(imgtool::stream *inp, imgtool::stream *out , unsigned len , bool add_eoln)
+static bool dump_string(imgtool::stream &inp, imgtool::stream &out , unsigned len , bool add_eoln)
{
UINT8 tmp[ SECTOR_LEN ];
@@ -1384,15 +1384,15 @@ static bool dump_string(imgtool::stream *inp, imgtool::stream *out , unsigned le
}
}
- out->write(tmp , len);
+ out.write(tmp , len);
if (add_eoln) {
- out->puts(EOLN);
+ out.puts(EOLN);
}
return true;
}
-static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtool::stream *inp_data;
imgtoolerr_t res;
@@ -1403,7 +1403,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
return IMGTOOLERR_OUTOFMEMORY;
}
- res = hp9845_tape_read_file(partition , filename , fork , inp_data);
+ res = hp9845_tape_read_file(partition , filename , fork , *inp_data);
if (res != IMGTOOLERR_SUCCESS) {
delete inp_data;
return res;
@@ -1418,7 +1418,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
do {
// Get record type
- if (!get_record_part(inp_data , tmp , 2)) {
+ if (!get_record_part(*inp_data , tmp , 2)) {
return IMGTOOLERR_READERROR;
}
rec_type = (UINT16)pick_integer_be(tmp , 0 , 2);
@@ -1441,7 +1441,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
return IMGTOOLERR_CORRUPTFILE;
}
- if (!get_record_part(inp_data , tmp , 2)) {
+ if (!get_record_part(*inp_data , tmp , 2)) {
return IMGTOOLERR_READERROR;
}
tmp_len = (unsigned)pick_integer_be(tmp , 0 , 2);
@@ -1456,14 +1456,14 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
if (rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR) {
rec_len = accum_len;
} else {
- rec_len = std::min(accum_len , len_to_eor(inp_data));
+ rec_len = std::min(accum_len , len_to_eor(*inp_data));
}
- if (!dump_string(inp_data , destf , rec_len , rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR)) {
+ if (!dump_string(*inp_data , destf , rec_len , rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR)) {
return IMGTOOLERR_READERROR;
}
if (rec_len & 1) {
// Keep length of string pieces even
- get_record_part(inp_data , tmp , 1);
+ get_record_part(*inp_data , tmp , 1);
}
accum_len -= rec_len;
break;
@@ -1481,7 +1481,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
return IMGTOOLERR_SUCCESS;
}
-static bool split_string_n_dump(const char *s , imgtool::stream *dest)
+static bool split_string_n_dump(const char *s , imgtool::stream &dest)
{
unsigned s_len = strlen(s);
UINT16 rec_type = REC_TYPE_1STSTR;
@@ -1494,7 +1494,7 @@ static bool split_string_n_dump(const char *s , imgtool::stream *dest)
// Not enough free space at end of current record: fill with EORs
place_integer_be(tmp , 0 , 2 , REC_TYPE_EOR);
while (free_len) {
- if (dest->write(tmp , 2) != 2) {
+ if (dest.write(tmp , 2) != 2) {
return false;
}
free_len -= 2;
@@ -1507,8 +1507,8 @@ static bool split_string_n_dump(const char *s , imgtool::stream *dest)
}
place_integer_be(tmp , 0 , 2 , rec_type);
place_integer_be(tmp , 2 , 2 , s_len);
- if (dest->write(tmp , 4) != 4 ||
- dest->write(s, s_part_len) != s_part_len) {
+ if (dest.write(tmp , 4) != 4 ||
+ dest.write(s, s_part_len) != s_part_len) {
return false;
}
rec_type = REC_TYPE_MIDSTR;
@@ -1520,20 +1520,20 @@ static bool split_string_n_dump(const char *s , imgtool::stream *dest)
place_integer_be(tmp , 0 , 2 , at_least_one ? REC_TYPE_ENDSTR : REC_TYPE_FULLSTR);
place_integer_be(tmp , 2 , 2 , s_len);
- if (dest->write(tmp , 4) != 4 ||
- dest->write(s , s_len) != s_len) {
+ if (dest.write(tmp , 4) != 4 ||
+ dest.write(s , s_len) != s_len) {
return false;
}
if (s_len & 1) {
tmp[ 0 ] = 0;
- if (dest->write(tmp , 1) != 1) {
+ if (dest.write(tmp , 1) != 1) {
return false;
}
}
return true;
}
-static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtool::stream *out_data;
@@ -1546,7 +1546,7 @@ static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const c
char line[ 256 ];
// Read input file one line at time
- if (sourcef->core_file()->gets(line , sizeof(line)) == nullptr) {
+ if (sourcef.core_file()->gets(line , sizeof(line)) == nullptr) {
// EOF
break;
}
@@ -1568,13 +1568,13 @@ static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const c
continue;
}
- if (!split_string_n_dump(line , out_data)) {
+ if (!split_string_n_dump(line, *out_data)) {
return IMGTOOLERR_WRITEERROR;
}
}
// Fill free space of last record with EOFs
- unsigned free_len = len_to_eor(out_data);
+ unsigned free_len = len_to_eor(*out_data);
UINT8 tmp[ 2 ];
place_integer_be(tmp , 0 , 2 , REC_TYPE_EOF);
@@ -1587,7 +1587,7 @@ static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const c
out_data->seek(0 , SEEK_SET);
- imgtoolerr_t res = hp9845_tape_write_file(partition , filename , fork , out_data , opts);
+ imgtoolerr_t res = hp9845_tape_write_file(partition, filename, fork, *out_data, opts);
delete out_data;
diff --git a/src/tools/imgtool/modules/mac.cpp b/src/tools/imgtool/modules/mac.cpp
index 98775a400b2..d51a3cf3539 100644
--- a/src/tools/imgtool/modules/mac.cpp
+++ b/src/tools/imgtool/modules/mac.cpp
@@ -1542,7 +1542,7 @@ struct mfs_dirref
-static imgtoolerr_t mfs_image_create(imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t mfs_image_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
imgtoolerr_t err;
UINT8 buffer[512];
@@ -1606,7 +1606,7 @@ static imgtoolerr_t mfs_image_create(imgtool::image *image, imgtool::stream *str
Return imgtool error code
*/
-static imgtoolerr_t mfs_image_open(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t mfs_image_open(imgtool::image *image, imgtool::stream &stream)
{
imgtoolerr_t err;
struct mac_l2_imgref *l2_img;
@@ -3033,7 +3033,7 @@ static int hfs_catKey_compare(const void *p1, const void *p2)
Return imgtool error code
*/
-static imgtoolerr_t hfs_image_open(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t hfs_image_open(imgtool::image *image, imgtool::stream &stream)
{
imgtoolerr_t err;
struct mac_l2_imgref *l2_img;
@@ -5277,8 +5277,8 @@ static void mac_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t mac_image_beginenum(imgtool::directory *enumeration, const char *path);
static imgtoolerr_t mac_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent);
static imgtoolerr_t mac_image_freespace(imgtool::partition *partition, UINT64 *size);
-static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf);
-static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions);
+static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
+static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions);
#ifdef UNUSED_FUNCTION
/*
@@ -5610,7 +5610,7 @@ static imgtoolerr_t mac_get_comment(struct mac_l2_imgref *image, mac_str255 file
/*
Extract a file from a disk image.
*/
-static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
imgtool::image *img = &partition->image();
@@ -5650,7 +5650,7 @@ static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char
err = mac_file_read(&fileref, run_len, buf);
if (err)
return err;
- if (destf->write(buf, run_len) != run_len)
+ if (destf.write(buf, run_len) != run_len)
return IMGTOOLERR_WRITEERROR;
i += run_len;
}
@@ -5661,7 +5661,7 @@ static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char
/*
Add a file to a disk image.
*/
-static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions)
+static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{
imgtool::image *img = &partition->image();
struct mac_l2_imgref *image = get_imgref(img);
@@ -5694,7 +5694,7 @@ static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const cha
memset(&cat_info, 0, sizeof(cat_info));
set_UINT32BE(&cat_info.flFinderInfo.type, 0x3F3F3F3F);
set_UINT32BE(&cat_info.flFinderInfo.creator, 0x3F3F3F3F);
- fork_len = sourcef->size();
+ fork_len = sourcef.size();
/*comment[0] = get_UINT16BE(header.comment_len);*/ /* comment length */
/* Next two fields are set to 0 with MFS volumes. IIRC, 0 normally
means system script: I don't think MFS stores the file name script code
@@ -5726,7 +5726,7 @@ static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const cha
run_len = fork_len - i;
if (run_len > 512)
run_len = 512;
- if (sourcef->read(buf, run_len) != run_len)
+ if (sourcef.read(buf, run_len) != run_len)
return IMGTOOLERR_READERROR;
err = mac_file_write(&fileref, run_len, buf);
if (err)
@@ -6213,7 +6213,7 @@ static imgtoolerr_t mac_image_geticoninfo(imgtool::partition *partition, const c
}
/* read in the resource fork */
- err = mac_image_readfile(partition, path, "RESOURCE_FORK", stream);
+ err = mac_image_readfile(partition, path, "RESOURCE_FORK", *stream);
if (err)
goto done;
resource_fork = stream->getptr();
diff --git a/src/tools/imgtool/modules/macbin.cpp b/src/tools/imgtool/modules/macbin.cpp
index ac61755996a..b18e6a70f80 100644
--- a/src/tools/imgtool/modules/macbin.cpp
+++ b/src/tools/imgtool/modules/macbin.cpp
@@ -63,7 +63,7 @@ static UINT32 pad128(UINT32 length)
-static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
static const UINT32 attrs[] =
{
@@ -156,7 +156,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
place_integer_be(header, 123, 1, 0x81);
place_integer_be(header, 124, 2, ccitt_crc16(0, header, 124));
- destf->write(header, sizeof(header));
+ destf.write(header, sizeof(header));
if (data_fork)
{
@@ -164,7 +164,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
if (err)
return err;
- destf->fill(0, pad128(data_fork->size));
+ destf.fill(0, pad128(data_fork->size));
}
if (resource_fork)
@@ -173,7 +173,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
if (err)
return err;
- destf->fill(0, pad128(resource_fork->size));
+ destf.fill(0, pad128(resource_fork->size));
}
return IMGTOOLERR_SUCCESS;
@@ -182,7 +182,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
static imgtoolerr_t write_fork(imgtool::partition *partition, const char *filename, const char *fork,
- imgtool::stream *sourcef, UINT64 pos, UINT64 fork_len, util::option_resolution *opts)
+ imgtool::stream &sourcef, UINT64 pos, UINT64 fork_len, util::option_resolution *opts)
{
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
imgtool::stream *mem_stream = NULL;
@@ -197,13 +197,13 @@ static imgtoolerr_t write_fork(imgtool::partition *partition, const char *filena
goto done;
}
- sourcef->seek(pos, SEEK_SET);
- len = imgtool::stream::transfer(*mem_stream, *sourcef, fork_len);
+ sourcef.seek(pos, SEEK_SET);
+ len = imgtool::stream::transfer(*mem_stream, sourcef, fork_len);
if (len < fork_len)
mem_stream->fill(0, fork_len);
mem_stream->seek(0, SEEK_SET);
- err = partition->write_file(filename, fork, mem_stream, opts, NULL);
+ err = partition->write_file(filename, fork, *mem_stream, opts, NULL);
if (err)
goto done;
}
@@ -216,7 +216,7 @@ done:
-static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
static const UINT32 attrs[] =
{
@@ -254,7 +254,7 @@ static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const cha
/* read in the header */
memset(header, 0, sizeof(header));
- sourcef->read(header, sizeof(header));
+ sourcef.read(header, sizeof(header));
/* check magic and zero fill bytes */
if (header[0] != 0x00)
@@ -266,7 +266,7 @@ static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const cha
datafork_size = pick_integer_be(header, 83, 4);
resourcefork_size = pick_integer_be(header, 87, 4);
- total_size = sourcef->size();
+ total_size = sourcef.size();
/* size of a MacBinary header is always 128 bytes */
if (total_size - pad128(datafork_size) - pad128(resourcefork_size) != 128)
@@ -342,7 +342,7 @@ static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const cha
-static imgtoolerr_t macbinary_checkstream(imgtool::stream *stream, imgtool_suggestion_viability_t *viability)
+static imgtoolerr_t macbinary_checkstream(imgtool::stream &stream, imgtool_suggestion_viability_t *viability)
{
imgtoolerr_t err;
diff --git a/src/tools/imgtool/modules/os9.cpp b/src/tools/imgtool/modules/os9.cpp
index c197b8fb5d7..f27a751f50a 100644
--- a/src/tools/imgtool/modules/os9.cpp
+++ b/src/tools/imgtool/modules/os9.cpp
@@ -622,7 +622,7 @@ done:
-static imgtoolerr_t os9_diskimage_open(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t os9_diskimage_open(imgtool::image *image, imgtool::stream &stream)
{
imgtoolerr_t err;
floperr_t ferr;
@@ -710,7 +710,7 @@ static imgtoolerr_t os9_diskimage_open(imgtool::image *image, imgtool::stream *s
-static imgtoolerr_t os9_diskimage_create(imgtool::image *img, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t os9_diskimage_create(imgtool::image *img, imgtool::stream &stream, util::option_resolution *opts)
{
imgtoolerr_t err;
dynamic_buffer header;
@@ -988,7 +988,7 @@ static imgtoolerr_t os9_diskimage_freespace(imgtool::partition *partition, UINT6
-static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
imgtool::image *img = &partition->image();
@@ -1017,7 +1017,7 @@ static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const
buffer, used_size);
if (err)
return err;
- destf->write(buffer, used_size);
+ destf.write(buffer, used_size);
file_size -= used_size;
}
}
@@ -1026,7 +1026,7 @@ static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const
-static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const char *path, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const char *path, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t err;
imgtool::image *image = &partition->image();
@@ -1047,7 +1047,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const
if (err)
goto done;
- sz = (UINT32) sourcef->size();
+ sz = (UINT32) sourcef.size();
err = os9_set_file_size(image, &file_info, sz);
if (err)
@@ -1057,7 +1057,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const
{
write_size = (std::min<UINT64>)(sz, disk_info->sector_size);
- sourcef->read(&buf[0], write_size);
+ sourcef.read(&buf[0], write_size);
while(count == 0)
{
diff --git a/src/tools/imgtool/modules/pc_flop.cpp b/src/tools/imgtool/modules/pc_flop.cpp
index dcda34e788e..5826a0b3747 100644
--- a/src/tools/imgtool/modules/pc_flop.cpp
+++ b/src/tools/imgtool/modules/pc_flop.cpp
@@ -17,7 +17,7 @@
#define FAT_SECLEN 512
-static imgtoolerr_t fat_image_create(imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t fat_image_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
imgtoolerr_t err;
UINT32 tracks, heads, sectors;
diff --git a/src/tools/imgtool/modules/pc_hard.cpp b/src/tools/imgtool/modules/pc_hard.cpp
index e913b5a7bf5..d195f8a7dcc 100644
--- a/src/tools/imgtool/modules/pc_hard.cpp
+++ b/src/tools/imgtool/modules/pc_hard.cpp
@@ -94,14 +94,14 @@ struct pc_chd_image_info
-static pc_chd_image_info *pc_chd_get_image_info(imgtool::image *image)
+static pc_chd_image_info *pc_chd_get_image_info(imgtool::image &image)
{
- return (pc_chd_image_info *) image->extra_bytes();
+ return (pc_chd_image_info *) image.extra_bytes();
}
-static void pc_chd_locate_block(imgtool::image *image, UINT64 block, UINT32 *cylinder, UINT32 *head, UINT32 *sector)
+static void pc_chd_locate_block(imgtool::image &image, UINT64 block, UINT32 *cylinder, UINT32 *head, UINT32 *sector)
{
pc_chd_image_info *info;
const hard_disk_info *hd_info;
@@ -116,7 +116,7 @@ static void pc_chd_locate_block(imgtool::image *image, UINT64 block, UINT32 *cyl
-static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition_index, UINT64 first_block, UINT64 block_count)
+static imgtoolerr_t pc_chd_partition_create(imgtool::image &image, int partition_index, UINT64 first_block, UINT64 block_count)
{
imgtoolerr_t err;
UINT8 header_block[FAT_SECLEN];
@@ -141,12 +141,12 @@ static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition
imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_PARTITION);
/* first create the actual partition */
- err = fat_partition_create(image, first_block, block_count);
+ err = fat_partition_create(&image, first_block, block_count);
if (err)
goto done;
/* read the first block of the partition, to determine the type of FAT */
- err = image->read_block(first_block, partition_block);
+ err = image.read_block(first_block, partition_block);
if (err)
goto done;
fat_type = &partition_block[54];
@@ -162,7 +162,7 @@ static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition
partition_type = 0x0B;
/* read the partition header */
- err = image->read_block(0, header_block);
+ err = image.read_block(0, header_block);
if (err)
goto done;
@@ -180,7 +180,7 @@ static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition
place_integer_le(partition_entry, 12, 4, block_count);
/* write the partition header */
- err = image->write_block(0, header_block);
+ err = image.write_block(0, header_block);
if (err)
goto done;
@@ -190,7 +190,7 @@ done:
-static imgtoolerr_t pc_chd_read_partition_header(imgtool::image *image)
+static imgtoolerr_t pc_chd_read_partition_header(imgtool::image &image)
{
imgtoolerr_t err;
int i;
@@ -201,7 +201,7 @@ static imgtoolerr_t pc_chd_read_partition_header(imgtool::image *image)
info = pc_chd_get_image_info(image);
/* read the initial block */
- err = image->read_block(0, buffer);
+ err = image.read_block(0, buffer);
if (err)
return err;
@@ -232,7 +232,7 @@ static imgtoolerr_t pc_chd_read_partition_header(imgtool::image *image)
-static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *opts)
+static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *opts)
{
imgtoolerr_t err;
UINT32 cylinders, heads, sectors;
@@ -243,7 +243,7 @@ static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool::stream *
heads = opts->lookup_int('H');
sectors = opts->lookup_int('S');
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
/* create the hard disk image */
err = imghd_create(f, 0, cylinders, heads, sectors, FAT_SECLEN);
@@ -262,11 +262,11 @@ static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool::stream *
if (err)
goto done;
- err = pc_chd_partition_create(image, 0, 1, cylinders * heads * sectors - 1);
+ err = pc_chd_partition_create(*image, 0, 1, cylinders * heads * sectors - 1);
if (err)
goto done;
- err = pc_chd_read_partition_header(image);
+ err = pc_chd_read_partition_header(*image);
if (err)
goto done;
@@ -278,19 +278,19 @@ done:
-static imgtoolerr_t pc_chd_image_open(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t pc_chd_image_open(imgtool::image *image, imgtool::stream &stream)
{
imgtoolerr_t err;
pc_chd_image_info *info;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
/* open the hard drive */
err = imghd_open(stream, &info->hard_disk);
if (err)
return err;
- err = pc_chd_read_partition_header(image);
+ err = pc_chd_read_partition_header(*image);
if (err)
return err;
@@ -302,7 +302,7 @@ static imgtoolerr_t pc_chd_image_open(imgtool::image *image, imgtool::stream *st
static void pc_chd_image_close(imgtool::image *image)
{
pc_chd_image_info *info;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
imghd_close(&info->hard_disk);
}
@@ -313,7 +313,7 @@ static imgtoolerr_t pc_chd_image_get_geometry(imgtool::image *image, UINT32 *tra
pc_chd_image_info *info;
const hard_disk_info *hd_info;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
hd_info = imghd_get_header(&info->hard_disk);
*tracks = hd_info->cylinders;
@@ -324,12 +324,12 @@ static imgtoolerr_t pc_chd_image_get_geometry(imgtool::image *image, UINT32 *tra
-static UINT32 pc_chd_calc_lbasector(pc_chd_image_info *info, UINT32 track, UINT32 head, UINT32 sector)
+static UINT32 pc_chd_calc_lbasector(pc_chd_image_info &info, UINT32 track, UINT32 head, UINT32 sector)
{
UINT32 lbasector;
const hard_disk_info *hd_info;
- hd_info = imghd_get_header(&info->hard_disk);
+ hd_info = imghd_get_header(&info.hard_disk);
lbasector = track;
lbasector *= hd_info->heads;
lbasector += head;
@@ -342,7 +342,7 @@ static UINT32 pc_chd_calc_lbasector(pc_chd_image_info *info, UINT32 track, UINT3
static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, std::vector<UINT8> &buffer)
{
- pc_chd_image_info *info = pc_chd_get_image_info(image);
+ pc_chd_image_info *info = pc_chd_get_image_info(*image);
// get the sector size and resize the buffer
UINT32 sector_size = imghd_get_header(&info->hard_disk)->sectorbytes;
@@ -351,7 +351,7 @@ static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track,
// read the data
return imghd_read(&info->hard_disk,
- pc_chd_calc_lbasector(info, track, head, sector),
+ pc_chd_calc_lbasector(*info, track, head, sector),
&buffer[0]);
}
@@ -360,9 +360,9 @@ static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track,
static imgtoolerr_t pc_chd_image_writesector(imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, const void *buffer, size_t len, int ddam)
{
pc_chd_image_info *info;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
return imghd_write(&info->hard_disk,
- pc_chd_calc_lbasector(info, track, head, sector),
+ pc_chd_calc_lbasector(*info, track, head, sector),
buffer);
}
@@ -371,7 +371,7 @@ static imgtoolerr_t pc_chd_image_writesector(imgtool::image *image, UINT32 track
static imgtoolerr_t pc_chd_image_readblock(imgtool::image *image, void *buffer, UINT64 block)
{
pc_chd_image_info *info;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
return imghd_read(&info->hard_disk, block, buffer);
}
@@ -380,7 +380,7 @@ static imgtoolerr_t pc_chd_image_readblock(imgtool::image *image, void *buffer,
static imgtoolerr_t pc_chd_image_writeblock(imgtool::image *image, const void *buffer, UINT64 block)
{
pc_chd_image_info *info;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
return imghd_write(&info->hard_disk, block, buffer);
}
@@ -391,7 +391,7 @@ static imgtoolerr_t pc_chd_list_partitions(imgtool::image *image, imgtool_partit
pc_chd_image_info *info;
size_t i;
- info = pc_chd_get_image_info(image);
+ info = pc_chd_get_image_info(*image);
for (i = 0; i < std::min(size_t(4), len); i++)
{
diff --git a/src/tools/imgtool/modules/prodos.cpp b/src/tools/imgtool/modules/prodos.cpp
index e0af8213777..e52986ee473 100644
--- a/src/tools/imgtool/modules/prodos.cpp
+++ b/src/tools/imgtool/modules/prodos.cpp
@@ -502,7 +502,7 @@ static imgtoolerr_t prodos_diskimage_open(imgtool::image *image)
-static imgtoolerr_t prodos_diskimage_open_525(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t prodos_diskimage_open_525(imgtool::image *image, imgtool::stream &stream)
{
prodos_setprocs_525(image);
return prodos_diskimage_open(image);
@@ -510,7 +510,7 @@ static imgtoolerr_t prodos_diskimage_open_525(imgtool::image *image, imgtool::st
-static imgtoolerr_t prodos_diskimage_open_35(imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t prodos_diskimage_open_35(imgtool::image *image, imgtool::stream &stream)
{
prodos_setprocs_35(image);
return prodos_diskimage_open(image);
@@ -702,7 +702,7 @@ static imgtoolerr_t prodos_diskimage_create(imgtool::image *image, util::option_
-static imgtoolerr_t prodos_diskimage_create_525(imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t prodos_diskimage_create_525(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
prodos_setprocs_525(image);
return prodos_diskimage_create(image, opts);
@@ -710,7 +710,7 @@ static imgtoolerr_t prodos_diskimage_create_525(imgtool::image *image, imgtool::
-static imgtoolerr_t prodos_diskimage_create_35(imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t prodos_diskimage_create_35(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
prodos_setprocs_35(image);
return prodos_diskimage_create(image, opts);
@@ -1571,7 +1571,7 @@ static imgtoolerr_t prodos_diskimage_nextenum(imgtool::directory *enumeration, i
static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesize,
- UINT32 block, int nest_level, imgtool::stream *destf)
+ UINT32 block, int nest_level, imgtool::stream &destf)
{
imgtoolerr_t err;
prodos_diskinfo *di;
@@ -1612,7 +1612,7 @@ static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesiz
{
/* this is a leaf block */
bytes_to_write = std::min(size_t(*filesize), sizeof(buffer));
- destf->write(buffer, bytes_to_write);
+ destf.write(buffer, bytes_to_write);
*filesize -= bytes_to_write;
}
return IMGTOOLERR_SUCCESS;
@@ -1621,7 +1621,7 @@ static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesiz
static imgtoolerr_t prodos_write_file_tree(imgtool::image *image, UINT32 *filesize,
- UINT32 block, int nest_level, imgtool::stream *sourcef)
+ UINT32 block, int nest_level, imgtool::stream &sourcef)
{
imgtoolerr_t err;
prodos_diskinfo *di;
@@ -1663,7 +1663,7 @@ static imgtoolerr_t prodos_write_file_tree(imgtool::image *image, UINT32 *filesi
{
/* this is a leaf block */
bytes_to_read = std::min(size_t(*filesize), sizeof(buffer));
- sourcef->read(buffer, bytes_to_read);
+ sourcef.read(buffer, bytes_to_read);
*filesize -= bytes_to_read;
err = prodos_save_block(image, block, buffer);
@@ -1704,7 +1704,7 @@ done:
-static imgtoolerr_t prodos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t prodos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
imgtool::image *image = &partition->image();
@@ -1737,14 +1737,14 @@ static imgtoolerr_t prodos_diskimage_readfile(imgtool::partition *partition, con
/* have we not actually received the correct amount of bytes? if not, fill in the rest */
if (ent.filesize[fork_num] > 0)
- destf->fill(0, ent.filesize[fork_num]);
+ destf.fill(0, ent.filesize[fork_num]);
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t prodos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t prodos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t err;
imgtool::image *image = &partition->image();
@@ -1753,7 +1753,7 @@ static imgtoolerr_t prodos_diskimage_writefile(imgtool::partition *partition, co
UINT64 file_size;
mac_fork_t fork_num;
- file_size = sourcef->size();
+ file_size = sourcef.size();
err = prodos_lookup_path(image, filename, CREATE_FILE, &direnum, &ent);
if (err)
diff --git a/src/tools/imgtool/modules/psion.cpp b/src/tools/imgtool/modules/psion.cpp
index 266391709c6..524c4c550ab 100644
--- a/src/tools/imgtool/modules/psion.cpp
+++ b/src/tools/imgtool/modules/psion.cpp
@@ -59,12 +59,12 @@ UINT16 head_checksum(UINT8* data)
return checksum;
}
-UINT16 get_long_rec_size(imgtool::stream *stream)
+UINT16 get_long_rec_size(imgtool::stream &stream)
{
UINT8 size_h, size_l;
- stream->read(&size_h, 1);
- stream->read(&size_l, 1);
+ stream.read(&size_h, 1);
+ stream.read(&size_l, 1);
return (size_h<<8) | size_l;
}
@@ -93,7 +93,7 @@ UINT32 update_pack_index(psion_pack *pack)
{
// long record without name are ignored
pack->stream->read(&data, 1);
- size = get_long_rec_size(pack->stream);
+ size = get_long_rec_size(*pack->stream);
pack->stream->seek(size, SEEK_CUR);
}
else
@@ -127,39 +127,39 @@ UINT32 update_pack_index(psion_pack *pack)
return FALSE;
}
-int seek_next_record(imgtool::stream *stream, UINT8 id)
+int seek_next_record(imgtool::stream &stream, UINT8 id)
{
UINT8 data, rec_id;
UINT16 size;
do
{
- stream->read(&data, 1);
+ stream.read(&data, 1);
if(data == 0xff)
break;
if (data == 2)
{
- stream->read(&rec_id, 1);
+ stream.read(&rec_id, 1);
size = get_long_rec_size(stream);
}
else
{
- stream->read(&rec_id, 1);
+ stream.read(&rec_id, 1);
if (id == rec_id)
{
- stream->seek(-2, SEEK_CUR);
+ stream.seek(-2, SEEK_CUR);
return TRUE;
}
size = data;
}
// next record
- stream->seek(size, SEEK_CUR);
+ stream.seek(size, SEEK_CUR);
- } while (stream->size() > stream->tell());
+ } while (stream.size() > stream.tell());
return FALSE;
}
@@ -194,7 +194,7 @@ UINT8 get_free_file_id(psion_pack *pack)
return 0xff;
}
-void put_name_record(imgtool::stream *stream, const char* filename, UINT8 record_type, UINT8 record_id)
+static void put_name_record(imgtool::stream &stream, const char* filename, UINT8 record_type, UINT8 record_id)
{
char data[0x10];
int i = 0;
@@ -211,35 +211,35 @@ void put_name_record(imgtool::stream *stream, const char* filename, UINT8 record
data[i++] = record_id;
- stream->write(data, i);
+ stream.write(data, i);
}
-void update_opk_head(imgtool::stream *stream)
+static void update_opk_head(imgtool::stream &stream)
{
- UINT16 size = stream->size() - 6;
+ UINT16 size = stream.size() - 6;
- stream->seek(4, SEEK_SET);
- stream->putc((size>>8) & 0xff);
- stream->putc(size & 0xff);
+ stream.seek(4, SEEK_SET);
+ stream.putc((size>>8) & 0xff);
+ stream.putc(size & 0xff);
}
-char *stream_getline(imgtool::stream *source, UINT16 max_len)
+char *stream_getline(imgtool::stream &source, UINT16 max_len)
{
UINT16 pos = 0;
char data;
char *line = (char*)malloc(max_len);
memset(line, 0, max_len);
- while (pos < max_len && source->size() > source->tell())
+ while (pos < max_len && source.size() > source.tell())
{
- source->read(&data, 1);
+ source.read(&data, 1);
switch(data)
{
case '\r':
- source->read(&data, 1);
+ source.read(&data, 1);
if (data != '\n')
- source->seek(-1, SEEK_CUR);
+ source.seek(-1, SEEK_CUR);
case '\n':
return line;
default:
@@ -255,21 +255,21 @@ char *stream_getline(imgtool::stream *source, UINT16 max_len)
return NULL;
}
-UINT16 put_odb(imgtool::stream *instream, imgtool::stream *outstream, UINT8 file_id)
+UINT16 put_odb(imgtool::stream &instream, imgtool::stream &outstream, UINT8 file_id)
{
char *line;
UINT16 out_size = 0;
// reset stream
- instream->seek(0, SEEK_SET);
+ instream.seek(0, SEEK_SET);
while ((line = stream_getline(instream, 256)))
{
UINT16 len = strlen(line);
- outstream->putc((UINT8)len);
- outstream->putc(file_id);
- outstream->write(line, len);
+ outstream.putc((UINT8)len);
+ outstream.putc(file_id);
+ outstream.write(line, len);
out_size += (len + 1);
@@ -277,37 +277,37 @@ UINT16 put_odb(imgtool::stream *instream, imgtool::stream *outstream, UINT8 file
}
// end of pack
- outstream->fill(0xff, 2);
+ outstream.fill(0xff, 2);
return out_size + 4;
}
-UINT16 put_ob3(imgtool::stream *instream, imgtool::stream *outstream)
+UINT16 put_ob3(imgtool::stream &instream, imgtool::stream &outstream)
{
- UINT16 size = instream->size() - 6;
+ UINT16 size = instream.size() - 6;
dynamic_buffer buffer(size);
- instream->seek(6, SEEK_SET);
- instream->read(&buffer[0], size);
+ instream.seek(6, SEEK_SET);
+ instream.read(&buffer[0], size);
- outstream->write(&buffer[0], size);
+ outstream.write(&buffer[0], size);
// end of pack
- outstream->fill(0xff, 2);
+ outstream.fill(0xff, 2);
return size;
}
-UINT16 put_opl(imgtool::stream *instream, imgtool::stream *outstream)
+UINT16 put_opl(imgtool::stream &instream, imgtool::stream &outstream)
{
UINT16 out_size = 0;
- UINT32 rec_start = outstream->tell();
+ UINT32 rec_start = outstream.tell();
char *line;
// reset stream
- instream->seek(0, SEEK_SET);
+ instream.seek(0, SEEK_SET);
- outstream->fill(0x00, 4);
+ outstream.fill(0x00, 4);
// replace all eol with 0x00
while ((line = stream_getline(instream, 256)))
@@ -316,24 +316,24 @@ UINT16 put_opl(imgtool::stream *instream, imgtool::stream *outstream)
for (int i=0; i<strlen(line); i++)
if (line[i] == '\t') line[i] = ' ';
- outstream->write(line, strlen(line));
- outstream->putc(0x00);
+ outstream.write(line, strlen(line));
+ outstream.putc(0x00);
out_size += strlen(line) + 1;
free(line);
}
// end of pack
- outstream->fill(0xff, 2);
+ outstream.fill(0xff, 2);
// update the size in the head
- outstream->seek(rec_start + 2, SEEK_SET);
- outstream->putc((out_size>>8) & 0xff);
- outstream->putc(out_size & 0xff);
+ outstream.seek(rec_start + 2, SEEK_SET);
+ outstream.putc((out_size>>8) & 0xff);
+ outstream.putc(out_size & 0xff);
return out_size + 4;
}
-UINT16 get_odb(imgtool::stream *instream, imgtool::stream *outstream, UINT8 type, UINT8 file_id)
+UINT16 get_odb(imgtool::stream &instream, imgtool::stream &outstream, UINT8 type, UINT8 file_id)
{
UINT8 data, *buffer;
UINT16 out_size = 0;
@@ -341,13 +341,13 @@ UINT16 get_odb(imgtool::stream *instream, imgtool::stream *outstream, UINT8 type
if (file_id >= 0x90)
while (seek_next_record(instream, file_id))
{
- instream->read(&data, 1);
- instream->seek(1, SEEK_CUR);
+ instream.read(&data, 1);
+ instream.seek(1, SEEK_CUR);
buffer = (UINT8*)malloc(data);
- instream->read(buffer, data);
- outstream->write(buffer, data);
- outstream->putc('\r');
- outstream->putc('\n');
+ instream.read(buffer, data);
+ outstream.write(buffer, data);
+ outstream.putc('\r');
+ outstream.putc('\n');
free (buffer);
out_size += data;
}
@@ -355,47 +355,47 @@ UINT16 get_odb(imgtool::stream *instream, imgtool::stream *outstream, UINT8 type
return out_size;
}
-UINT16 get_ob3(imgtool::stream *instream, imgtool::stream *outstream, UINT8 type, UINT8 file_id)
+UINT16 get_ob3(imgtool::stream &instream, imgtool::stream &outstream, UINT8 type, UINT8 file_id)
{
UINT8 data, *buffer = NULL;
UINT16 size = 0;
static const char ob3_magic[3] = {'O', 'R', 'G'};
- instream->read(&data, 1);
+ instream.read(&data, 1);
if (data == 0x02)
{
- instream->seek(1, SEEK_CUR);
+ instream.seek(1, SEEK_CUR);
size = get_long_rec_size(instream);
buffer = (UINT8*)malloc(size);
- instream->read(buffer, size);
+ instream.read(buffer, size);
}
- outstream->write(ob3_magic, 3);
- outstream->putc((size>>8) & 0xff);
- outstream->putc(size & 0xff);
- outstream->putc(type | 0x80);
+ outstream.write(ob3_magic, 3);
+ outstream.putc((size>>8) & 0xff);
+ outstream.putc(size & 0xff);
+ outstream.putc(type | 0x80);
if (buffer)
{
- outstream->write(buffer, size);
+ outstream.write(buffer, size);
free (buffer);
}
return size;
}
-static imgtoolerr_t datapack_open( imgtool::image *image, imgtool::stream *stream)
+static imgtoolerr_t datapack_open(imgtool::image *image, imgtool::stream &stream)
{
psion_pack *pack = (psion_pack*)image->extra_bytes();
char opk_magic[4];
- stream->read(opk_magic, 4);
+ stream.read(opk_magic, 4);
if(strcmp(opk_magic, "OPK\0"))
return IMGTOOLERR_UNEXPECTED;
- pack->stream = stream;
+ pack->stream = &stream;
if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS;
@@ -403,7 +403,7 @@ static imgtoolerr_t datapack_open( imgtool::image *image, imgtool::stream *strea
return IMGTOOLERR_CORRUPTIMAGE;
}
-static imgtoolerr_t datapack_create( imgtool::image *image, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t datapack_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{
psion_pack *pack = (psion_pack*)image->extra_bytes();
static const UINT8 opk_magic[4] = {'O', 'P', 'K', 0x00};
@@ -419,20 +419,20 @@ static imgtoolerr_t datapack_create( imgtool::image *image, imgtool::stream *str
checksum = head_checksum(pack_head);
- stream->write(opk_magic, 4);
- stream->fill(0x00, 2);
- stream->write(pack_head, 8);
+ stream.write(opk_magic, 4);
+ stream.fill(0x00, 2);
+ stream.write(pack_head, 8);
- stream->putc((checksum>>8) & 0xff);
- stream->putc(checksum & 0xff);
+ stream.putc((checksum>>8) & 0xff);
+ stream.putc(checksum & 0xff);
put_name_record(stream, "MAIN", 0x81, 0x90);
- stream->fill(0xff, 2);
+ stream.fill(0xff, 2);
update_opk_head(stream);
- pack->stream = stream;
+ pack->stream = &stream;
if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS;
@@ -473,14 +473,14 @@ static imgtoolerr_t datapack_next_enum(imgtool::directory *enumeration, imgtool_
if (pack->pack_index[iter->index].data_rec)
{
pack->stream->seek(pack->pack_index[iter->index].data_rec + 2, SEEK_SET);
- ent->filesize = get_long_rec_size(pack->stream);
+ ent->filesize = get_long_rec_size(*pack->stream);
}
// seek all file's records
if (pack->pack_index[iter->index].id >= 0x90)
{
pack->stream->seek(0x10, SEEK_SET);
- while (seek_next_record(pack->stream, pack->pack_index[iter->index].id))
+ while (seek_next_record(*pack->stream, pack->pack_index[iter->index].id))
{
pack->stream->read(&data, 1);
pack->stream->seek(data + 1, SEEK_CUR);
@@ -511,7 +511,7 @@ static imgtoolerr_t datapack_free_space( imgtool::partition *partition, UINT64 *
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtool::image *image = &partition->image();
psion_pack *pack = (psion_pack*)image->extra_bytes();
@@ -523,13 +523,13 @@ static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char
{
// ODB files
pack->stream->seek(0x10, SEEK_SET);
- get_odb(pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id);
+ get_odb(*pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id);
}
else if ((pack->pack_index[index].type & 0x7f) == 0x03)
{
// OB3/OPL files
pack->stream->seek(pack->pack_index[index].data_rec, SEEK_SET);
- get_ob3(pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id);
+ get_ob3(*pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id);
}
else
{
@@ -543,7 +543,7 @@ static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char
return IMGTOOLERR_FILENOTFOUND;
}
-static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtool::image *image = &partition->image();
psion_pack *pack = (psion_pack*)image->extra_bytes();
@@ -565,7 +565,7 @@ static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const ch
return IMGTOOLERR_NOSPACE;
}
- sourcef->read(head, 3);
+ sourcef.read(head, 3);
pack->stream->seek(pack->eop, SEEK_SET);
if (type == 0)
@@ -574,18 +574,18 @@ static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const ch
switch (type)
{
case 1: //OB3 file
- put_name_record(pack->stream, filename, 0x83, file_id);
+ put_name_record(*pack->stream, filename, 0x83, file_id);
pack->stream->write(data_head, 4);
- size = put_ob3(sourcef, pack->stream);
+ size = put_ob3(sourcef, *pack->stream);
break;
case 2: //OPL file
- put_name_record(pack->stream, filename, 0x83, file_id);
+ put_name_record(*pack->stream, filename, 0x83, file_id);
pack->stream->write(data_head, 4);
- size = put_opl(sourcef, pack->stream);
+ size = put_opl(sourcef, *pack->stream);
break;
case 3: //ODB file
- put_name_record(pack->stream, filename, 0x81, file_id);
- size = put_odb(sourcef, pack->stream, file_id);
+ put_name_record(*pack->stream, filename, 0x81, file_id);
+ size = put_odb(sourcef, *pack->stream, file_id);
break;
}
@@ -597,7 +597,7 @@ static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const ch
pack->stream->putc(size & 0xff);
}
- update_opk_head(pack->stream);
+ update_opk_head(*pack->stream);
if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS;
diff --git a/src/tools/imgtool/modules/rsdos.cpp b/src/tools/imgtool/modules/rsdos.cpp
index 7934098c1bb..501a50e814e 100644
--- a/src/tools/imgtool/modules/rsdos.cpp
+++ b/src/tools/imgtool/modules/rsdos.cpp
@@ -149,7 +149,7 @@ static floperr_t put_granule_map(imgtool::image *img, const UINT8 *granule_map,
-static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream *f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool::stream *))
+static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool::stream &))
{
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
UINT8 track, sector;
@@ -167,14 +167,14 @@ static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int len
-static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream *destf)
+static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &destf)
{
return transfer_granule(img, granule, length, destf, imgtool_floppy_read_sector_to_stream);
}
-static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream *sourcef)
+static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &sourcef)
{
return transfer_granule(img, granule, length, sourcef, imgtool_floppy_write_sector_from_stream);
}
@@ -204,7 +204,7 @@ static imgtoolerr_t process_rsdos_file(struct rsdos_dirent *ent, imgtool::image
{
usedmap[granule] = 1;
if (destf)
- transfer_from_granule(img, granule, 9*256, destf);
+ transfer_from_granule(img, granule, 9*256, *destf);
/* i is the next granule */
s += (256 * 9);
@@ -219,7 +219,7 @@ static imgtoolerr_t process_rsdos_file(struct rsdos_dirent *ent, imgtool::image
lastgransize += (256 * (i - 0xc0));
if (destf)
- transfer_from_granule(img, granule, lastgransize, destf);
+ transfer_from_granule(img, granule, lastgransize, *destf);
if (size)
*size = s + lastgransize;
@@ -300,7 +300,7 @@ eof:
else
{
/* Not the end of file */
- err = process_rsdos_file(&rsent, image, NULL, &filesize);
+ err = process_rsdos_file(&rsent, image, nullptr, &filesize);
if (err)
return err;
@@ -386,7 +386,7 @@ static imgtoolerr_t delete_entry(imgtool::image *img, struct rsdos_dirent *ent,
-static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t err;
struct rsdos_dirent ent;
@@ -397,7 +397,7 @@ static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, cons
if (err)
return err;
- err = process_rsdos_file(&ent, img, destf, &size);
+ err = process_rsdos_file(&ent, img, &destf, &size);
if (err)
return err;
@@ -409,7 +409,7 @@ static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, cons
-static imgtoolerr_t rsdos_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions)
+static imgtoolerr_t rsdos_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{
floperr_t ferr;
imgtoolerr_t err;
@@ -432,7 +432,7 @@ static imgtoolerr_t rsdos_diskimage_writefile(imgtool::partition *partition, con
return err;
/* is there enough space? */
- sz = sourcef->size();
+ sz = sourcef.size();
if (sz > freespace)
return IMGTOOLERR_NOSPACE;
diff --git a/src/tools/imgtool/modules/thomson.cpp b/src/tools/imgtool/modules/thomson.cpp
index 22c1cceeb92..96e7c5547f3 100644
--- a/src/tools/imgtool/modules/thomson.cpp
+++ b/src/tools/imgtool/modules/thomson.cpp
@@ -177,12 +177,12 @@ static UINT8* thom_get_sector(thom_floppy* f, unsigned head,
(.fd have 40 or 80 tracks, .qd have 25 tracks) and the file size.
*/
-static imgtoolerr_t thom_open_fd_qd(imgtool::image *img, imgtool::stream *stream)
+static imgtoolerr_t thom_open_fd_qd(imgtool::image *img, imgtool::stream &stream)
{
thom_floppy* f = (thom_floppy*) img->extra_bytes();
- int size = stream->size();
+ int size = stream.size();
- f->stream = stream;
+ f->stream = &stream;
f->modified = 0;
/* guess format */
@@ -238,8 +238,8 @@ static imgtoolerr_t thom_open_fd_qd(imgtool::image *img, imgtool::stream *stream
assert( size == f->heads * f->tracks * 16 * f->sector_size );
- stream->seek(0, SEEK_SET);
- if ( stream->read(f->data, size ) < size )
+ stream.seek(0, SEEK_SET);
+ if ( stream.read(f->data, size ) < size )
return IMGTOOLERR_READERROR;
return IMGTOOLERR_SUCCESS;
@@ -308,21 +308,21 @@ static UINT16 thom_sap_crc( UINT8* data, int size )
return crc;
}
-static imgtoolerr_t thom_open_sap(imgtool::image *img, imgtool::stream *stream)
+static imgtoolerr_t thom_open_sap(imgtool::image *img, imgtool::stream &stream)
{
thom_floppy* f = (thom_floppy*) img->extra_bytes();
UINT8 buf[262];
- f->stream = stream;
+ f->stream = &stream;
f->modified = 0;
/* check image header */
- stream->seek(0, SEEK_SET);
- stream->read(buf, 66 );
+ stream.seek(0, SEEK_SET);
+ stream.read(buf, 66 );
if ( memcmp( buf+1, sap_header+1, 65 ) ) return IMGTOOLERR_CORRUPTIMAGE;
/* guess format */
- stream->read(buf, 1 );
+ stream.read(buf, 1 );
switch ( buf[0] ) {
case 1:
case 3:
@@ -342,13 +342,13 @@ static imgtoolerr_t thom_open_sap(imgtool::image *img, imgtool::stream *stream)
default: return IMGTOOLERR_CORRUPTIMAGE;
}
- stream->seek(66, SEEK_SET);
+ stream.seek(66, SEEK_SET);
while ( 1) {
int i, sector, track;
UINT16 crc;
/* load sector */
- if ( stream->read(buf, 6 + f->sector_size ) < 6 + f->sector_size )
+ if ( stream.read(buf, 6 + f->sector_size ) < 6 + f->sector_size )
break;
/* parse sector header */
@@ -678,7 +678,7 @@ static int thom_get_free_blocks(thom_floppy* f, unsigned head)
/* dump file contents into dst */
static void thom_get_file(thom_floppy* f, unsigned head,
- thom_dirent* d, imgtool::stream *dst)
+ thom_dirent* d, imgtool::stream &dst)
{
UINT8* fat = thom_get_sector( f, head, 20, 2 );
int nbblocks = thom_nb_blocks(f);
@@ -693,7 +693,7 @@ static void thom_get_file(thom_floppy* f, unsigned head,
int i;
for ( i = 0; i < 8; i++ ) {
UINT8* data = thom_get_sector( f, head, track, firstsect + i );
- dst->write(data, f->sectuse_size);
+ dst.write(data, f->sectuse_size);
}
block = fat[ block + 1 ];
}
@@ -703,16 +703,16 @@ static void thom_get_file(thom_floppy* f, unsigned head,
UINT8* data;
for ( i = 0; i < nextblock - 0xc1; i++ ) {
data = thom_get_sector( f, head, track, firstsect + i );
- dst->write(data, f->sectuse_size);
+ dst.write(data, f->sectuse_size);
}
data = thom_get_sector( f, head, track, firstsect + i );
- dst->write(data, d->lastsectsize);
+ dst.write(data, d->lastsectsize);
return;
}
else {
/* invalid, assume last block */
UINT8* data = thom_get_sector( f, head, track, firstsect );
- dst->write(data, d->lastsectsize);
+ dst.write(data, d->lastsectsize);
return;
}
block = nextblock;
@@ -739,9 +739,9 @@ static void thom_del_file(thom_floppy* f, unsigned head, thom_dirent* d)
/* create a new file or overwrite an old one, with the contents of src */
static void thom_put_file(thom_floppy* f, unsigned head,
- thom_dirent* d, imgtool::stream *src)
+ thom_dirent* d, imgtool::stream &src)
{
- int size = src->size();
+ int size = src.size();
UINT8* fat = thom_get_sector( f, head, 20, 2 );
int nbblocks = thom_nb_blocks(f);
int block;
@@ -760,14 +760,14 @@ static void thom_put_file(thom_floppy* f, unsigned head,
/* store data, full sectors */
for ( i = 0; i < 8 && size > f->sectuse_size; i++ ) {
UINT8* dst = thom_get_sector( f, head, track, firstsect + i );
- src->read(dst, f->sectuse_size );
+ src.read(dst, f->sectuse_size );
size -= f->sectuse_size;
}
/* store data, last sector */
if ( i < 8 ) {
UINT8* dst = thom_get_sector( f, head, track, firstsect + i );
- src->read(dst, size );
+ src.read(dst, size );
fat[ block + 1 ] = 0xc1 + i;
d->lastsectsize = size;
break;
@@ -937,7 +937,7 @@ static imgtoolerr_t thom_free_space(imgtool::partition *part, UINT64 *size)
static imgtoolerr_t thom_read_file(imgtool::partition *part,
const char *filename,
const char *fork,
- imgtool::stream *destf)
+ imgtool::stream &destf)
{
int head = *( (int*) part->extra_bytes() );
imgtool::image* img = &part->image();
@@ -982,14 +982,14 @@ static imgtoolerr_t thom_delete_file(imgtool::partition *part,
static imgtoolerr_t thom_write_file(imgtool::partition *part,
const char *filename,
const char *fork,
- imgtool::stream *sourcef,
+ imgtool::stream &sourcef,
util::option_resolution *opts)
{
int head = *( (int*) part->extra_bytes() );
imgtool::image* img = &part->image();
thom_floppy* f = (thom_floppy*) img->extra_bytes();
thom_dirent d;
- int size = sourcef->size();
+ int size = sourcef.size();
int blocks = thom_get_free_blocks( f, head );
char name[9], ext[4], fname[14];
int is_new = 1;
@@ -1107,7 +1107,7 @@ static imgtoolerr_t thom_suggest_transfer(imgtool::partition *part,
}
static imgtoolerr_t thom_create(imgtool::image* img,
- imgtool::stream *stream,
+ imgtool::stream &stream,
util::option_resolution *opts)
{
thom_floppy* f = (thom_floppy*) img->extra_bytes();
@@ -1115,7 +1115,7 @@ static imgtoolerr_t thom_create(imgtool::image* img,
UINT8* buf;
const char* name;
- f->stream = stream;
+ f->stream = &stream;
f->modified = 0;
/* get parameters */
@@ -1274,38 +1274,40 @@ static const UINT8 crypt2[13] = {
};
/* decrypt BASIC protected files */
-static void thom_decrypt(imgtool::stream* out, imgtool::stream* in)
+static void thom_decrypt(imgtool::stream &out, imgtool::stream &in)
{
int i1 = 11, i2 = 13;
- while ( 1 ) {
- UINT8 b;
- if ( in->read(&b, 1) < 1 ) break;
- b = ( (UINT8)(b - i2) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i1;
- out->putc(b );
- i1--; i2--;
- if ( !i1 ) i1 = 11;
- if ( !i2 ) i2 = 13;
+ while ( 1 )
+ {
+ UINT8 b;
+ if ( in.read(&b, 1) < 1 ) break;
+ b = ( (UINT8)(b - i2) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i1;
+ out.putc(b );
+ i1--; i2--;
+ if ( !i1 ) i1 = 11;
+ if ( !i2 ) i2 = 13;
}
}
/* encrypt BASIC protected files */
-static void thom_encrypt(imgtool::stream* out, imgtool::stream* in)
+static void thom_encrypt(imgtool::stream &out, imgtool::stream &in)
{
int i1 = 11, i2 = 13;
- while ( 1 ) {
- UINT8 b;
- if ( in->read(&b, 1) < 1 ) break;
- b = ( (UINT8)(b - i1) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i2;
- out->putc(b );
- i1--; i2--;
- if ( !i1 ) i1 = 11;
- if ( !i2 ) i2 = 13;
+ while ( 1 )
+ {
+ UINT8 b;
+ if ( in.read(&b, 1) < 1 ) break;
+ b = ( (UINT8)(b - i1) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i2;
+ out.putc(b );
+ i1--; i2--;
+ if ( !i1 ) i1 = 11;
+ if ( !i2 ) i2 = 13;
}
}
static imgtoolerr_t thomcrypt_read_file(imgtool::partition *part,
const char *name,
- const char *fork, imgtool::stream *dst)
+ const char *fork, imgtool::stream &dst)
{
UINT8 buf[3];
imgtool::stream *org = imgtool::stream::open_mem( NULL, 0 );
@@ -1313,23 +1315,25 @@ static imgtoolerr_t thomcrypt_read_file(imgtool::partition *part,
if ( !org ) return IMGTOOLERR_OUTOFMEMORY;
/* read file */
- err = thom_read_file( part, name, fork, org );
+ err = thom_read_file( part, name, fork, *org );
if ( err ) {
delete org;
return err;
}
org->seek(0, SEEK_SET);
- if ( org->read(buf, 3 ) < 3 || buf[0] != 0xfe ) {
- /* regular file */
- org->seek(0, SEEK_SET);
- imgtool::stream::transfer_all( *dst, *org );
+ if ( org->read(buf, 3 ) < 3 || buf[0] != 0xfe )
+ {
+ /* regular file */
+ org->seek(0, SEEK_SET);
+ imgtool::stream::transfer_all( dst, *org );
}
- else {
- /* encrypted file */
- dst->putc( '\xff' );
- dst->write(buf+1, 2);
- thom_decrypt( dst, org );
+ else
+ {
+ /* encrypted file */
+ dst.putc( '\xff' );
+ dst.write(buf+1, 2);
+ thom_decrypt( dst, *org );
}
delete org;
@@ -1338,28 +1342,30 @@ static imgtoolerr_t thomcrypt_read_file(imgtool::partition *part,
static imgtoolerr_t thomcrypt_write_file(imgtool::partition *part,
const char *name,
- const char *fork, imgtool::stream *src,
+ const char *fork, imgtool::stream &src,
util::option_resolution *opts)
{
UINT8 buf[3];
- if ( src->read(buf, 3 ) < 3 || buf[0] == 0xfe ) {
- /* too short or already encrypted file */
- src->seek(0, SEEK_SET);
- return thom_write_file( part, name, fork, src, opts );
+ if ( src.read(buf, 3 ) < 3 || buf[0] == 0xfe )
+ {
+ /* too short or already encrypted file */
+ src.seek(0, SEEK_SET);
+ return thom_write_file( part, name, fork, src, opts );
}
- else {
- /* regular file */
- imgtool::stream *dst = imgtool::stream::open_mem( NULL, 0 );
- imgtoolerr_t err;
- if ( !dst ) return IMGTOOLERR_OUTOFMEMORY;
- dst->putc( '\xfe' );
- dst->write(buf+1, 2);
- thom_encrypt( dst, src );
- dst->seek(0, SEEK_SET);
- err = thom_write_file( part, name, fork, dst, opts );
- delete dst;
- return err;
+ else
+ {
+ /* regular file */
+ imgtool::stream *dst = imgtool::stream::open_mem( NULL, 0 );
+ imgtoolerr_t err;
+ if ( !dst ) return IMGTOOLERR_OUTOFMEMORY;
+ dst->putc( '\xfe' );
+ dst->write(buf+1, 2);
+ thom_encrypt( *dst, src );
+ dst->seek(0, SEEK_SET);
+ err = thom_write_file( part, name, fork, *dst, opts );
+ delete dst;
+ return err;
}
}
@@ -1385,7 +1391,7 @@ void filter_thomcrypt_getinfo(UINT32 state, union filterinfo *info)
static imgtoolerr_t thom_basic_read_file(imgtool::partition *part,
const char *name,
const char *fork,
- imgtool::stream *dst,
+ imgtool::stream &dst,
const char *const table[2][128])
{
imgtool::stream *org = imgtool::stream::open_mem( NULL, 0 );
@@ -1395,7 +1401,7 @@ static imgtoolerr_t thom_basic_read_file(imgtool::partition *part,
if ( !org ) return IMGTOOLERR_OUTOFMEMORY;
- err = thomcrypt_read_file( part, name, fork, org );
+ err = thomcrypt_read_file( part, name, fork, *org );
if (err)
{
delete org;
@@ -1414,7 +1420,7 @@ static imgtoolerr_t thom_basic_read_file(imgtool::partition *part,
if ( linelength <= 0 ) goto end;
if ( org->read(buf, 2 ) < 2 ) goto end;
linenum = ((int)buf[0] << 8) + buf[1];
- dst->printf( "%u ", linenum );
+ dst.printf( "%u ", linenum );
/* process line */
for ( i = 0; i < linelength; i++ ) {
@@ -1434,18 +1440,18 @@ static imgtoolerr_t thom_basic_read_file(imgtool::partition *part,
if ( c >= 0x80 && ! in_str ) {
/* token */
const char* token = table[ in_fun ][ c - 0x80 ];
- if ( token ) dst->puts(token );
- else dst->puts("???" );
+ if ( token ) dst.puts(token );
+ else dst.puts("???" );
}
else {
/* regular character */
if ( c == '"' ) in_str = 1 - in_str;
- dst->putc( c ); /* normal letter */
+ dst.putc( c ); /* normal letter */
}
in_fun = 0;
}
}
- dst->putc( '\n' );
+ dst.putc( '\n' );
}
end:
@@ -1456,7 +1462,7 @@ static imgtoolerr_t thom_basic_read_file(imgtool::partition *part,
static imgtoolerr_t thom_basic_write_file(imgtool::partition *part,
const char *name,
const char *fork,
- imgtool::stream *src,
+ imgtool::stream &src,
util::option_resolution *opts,
const char *const table[2][128])
{
@@ -1468,14 +1474,14 @@ static imgtoolerr_t thom_basic_write_file(imgtool::partition *part,
static imgtoolerr_t short##_read_file(imgtool::partition *part, \
const char *name, \
const char *fork, \
- imgtool::stream *dst) \
+ imgtool::stream &dst) \
{ \
return thom_basic_read_file( part, name, fork, dst, short ); \
} \
static imgtoolerr_t short##_write_file(imgtool::partition *part, \
const char *name, \
const char *fork, \
- imgtool::stream *src, \
+ imgtool::stream &src, \
util::option_resolution *opts) \
{ \
return thom_basic_write_file( part, name, fork, src, opts, short ); \
diff --git a/src/tools/imgtool/modules/ti99.cpp b/src/tools/imgtool/modules/ti99.cpp
index f34eebf95d6..1682712ec15 100644
--- a/src/tools/imgtool/modules/ti99.cpp
+++ b/src/tools/imgtool/modules/ti99.cpp
@@ -597,7 +597,7 @@ static void calc_crc(UINT16 *crc, UINT8 value)
*/
#define MAX_TRACK_LEN 6872
#define DATA_OFFSET_NONE 0xffffffff
-static int parse_pc99_image(imgtool::stream *file_handle, int fm_format, int pass, dsk_vib *vib, const ti99_geometry *geometry, UINT32 *data_offset_array, unsigned *out_track_len)
+static int parse_pc99_image(imgtool::stream &file_handle, int fm_format, int pass, dsk_vib *vib, const ti99_geometry *geometry, UINT32 *data_offset_array, unsigned *out_track_len)
{
int track_len, num_tracks; /* length of a track in bytes, and number of tracks */
int phys_track;
@@ -620,10 +620,10 @@ static int parse_pc99_image(imgtool::stream *file_handle, int fm_format, int pas
if (out_track_len)
*out_track_len = track_len;
- if (file_handle->size() % track_len)
+ if (file_handle.size() % track_len)
return IMGTOOLERR_CORRUPTIMAGE;
- num_tracks = file_handle->size() / track_len;
+ num_tracks = file_handle.size() / track_len;
if (num_tracks <= 0)
return IMGTOOLERR_CORRUPTIMAGE;
@@ -640,12 +640,12 @@ static int parse_pc99_image(imgtool::stream *file_handle, int fm_format, int pas
data_offset_array[(head*geometry->cylinders + cylinder)*geometry->secspertrack + sector] = DATA_OFFSET_NONE;
}
/* rewind to start of file */
- file_handle->seek(0, SEEK_SET);
+ file_handle.seek(0, SEEK_SET);
/* pass 0 only looks for vib in track 0; pass 1 scans every track */
for (phys_track=0; phys_track < ((pass == 1) ? num_tracks : 1); phys_track++)
{
- if (file_handle->read(track_buf, track_len) != track_len)
+ if (file_handle.read(track_buf, track_len) != track_len)
return IMGTOOLERR_READERROR;
/* we only support 40-track-per-side images */
@@ -926,7 +926,7 @@ static int parse_pc99_image(imgtool::stream *file_handle, int fm_format, int pas
Return imgtool error code
*/
-static int read_image_vib_no_geometry(imgtool::stream *file_handle, ti99_img_format img_format, dsk_vib *dest)
+static int read_image_vib_no_geometry(imgtool::stream &file_handle, ti99_img_format img_format, dsk_vib *dest)
{
int reply;
@@ -935,11 +935,11 @@ static int read_image_vib_no_geometry(imgtool::stream *file_handle, ti99_img_for
case if_mess:
case if_v9t9:
/* seek to sector */
- reply = file_handle->seek(0, SEEK_SET);
+ reply = file_handle.seek(0, SEEK_SET);
if (reply)
return IMGTOOLERR_READERROR;
/* read it */
- reply = file_handle->read(dest, 256);
+ reply = file_handle.read(dest, 256);
if (reply != 256)
return IMGTOOLERR_READERROR;
return 0;
@@ -966,7 +966,7 @@ static int read_image_vib_no_geometry(imgtool::stream *file_handle, ti99_img_for
Return imgtool error code
*/
-static imgtoolerr_t open_image_lvl1(imgtool::stream *file_handle, ti99_img_format img_format, ti99_lvl1_imgref *l1_img, dsk_vib *vib)
+static imgtoolerr_t open_image_lvl1(imgtool::stream &file_handle, ti99_img_format img_format, ti99_lvl1_imgref *l1_img, dsk_vib *vib)
{
imgtoolerr_t err;
int reply;
@@ -974,7 +974,7 @@ static imgtoolerr_t open_image_lvl1(imgtool::stream *file_handle, ti99_img_forma
l1_img->img_format = img_format;
- l1_img->file_handle = file_handle;
+ l1_img->file_handle = &file_handle;
if (img_format == if_harddisk)
{
@@ -1032,7 +1032,7 @@ static imgtoolerr_t open_image_lvl1(imgtool::stream *file_handle, ti99_img_forma
|| (totphysrecs < 2)
|| memcmp(vib->id, "DSK", 3) || (! strchr(" P", vib->protection))
|| (((img_format == if_mess) || (img_format == if_v9t9))
- && (file_handle->size() != totphysrecs*256U)))
+ && (file_handle.size() != totphysrecs*256U)))
return (imgtoolerr_t)IMGTOOLERR_CORRUPTIMAGE;
if ((img_format == if_pc99_fm) || (img_format == if_pc99_mfm))
@@ -2909,11 +2909,11 @@ static int new_file_lvl2_win(struct ti99_lvl2_imgref *l2_img, ti99_catalog *pare
/*
Allocate a new (empty) file
*/
-static int new_file_lvl2_tifiles(imgtool::stream *file_handle, struct ti99_lvl2_fileref *l2_file)
+static int new_file_lvl2_tifiles(imgtool::stream &file_handle, struct ti99_lvl2_fileref *l2_file)
{
/* set up file handle */
l2_file->type = L2F_TIFILES;
- l2_file->tifiles.file_handle = file_handle;
+ l2_file->tifiles.file_handle = &file_handle;
memset(&l2_file->tifiles.hdr, 0, sizeof(l2_file->tifiles.hdr));
l2_file->tifiles.hdr.tifiles[0] = '\7';
l2_file->tifiles.hdr.tifiles[1] = 'T';
@@ -3087,11 +3087,11 @@ static int open_file_lvl2_win(struct ti99_lvl2_imgref *l2_img, const char *fpath
/*
Open an existing file in TIFILES format
*/
-static int open_file_lvl2_tifiles(imgtool::stream *file_handle, struct ti99_lvl2_fileref *l2_file)
+static int open_file_lvl2_tifiles(imgtool::stream &file_handle, struct ti99_lvl2_fileref *l2_file)
{
/* set up file handle */
l2_file->type = L2F_TIFILES;
- l2_file->tifiles.file_handle = file_handle;
+ l2_file->tifiles.file_handle = &file_handle;
/* seek to header */
if (l2_file->tifiles.file_handle->seek(0, SEEK_SET))
@@ -3848,11 +3848,11 @@ struct win_iterator
};
-static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream *f);
-static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream *f);
-static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::stream *f);
-static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stream *f);
-static imgtoolerr_t win_image_init(imgtool::image *image, imgtool::stream *f);
+static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream &f);
+static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream &f);
+static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::stream &f);
+static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stream &f);
+static imgtoolerr_t win_image_init(imgtool::image *image, imgtool::stream &f);
static void ti99_image_exit(imgtool::image *img);
static void ti99_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t dsk_image_beginenum(imgtool::directory *enumeration, const char *path);
@@ -3860,12 +3860,12 @@ static imgtoolerr_t dsk_image_nextenum(imgtool::directory *enumeration, imgtool_
static imgtoolerr_t win_image_beginenum(imgtool::directory *enumeration, const char *path);
static imgtoolerr_t win_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent);
static imgtoolerr_t ti99_image_freespace(imgtool::partition *partition, UINT64 *size);
-static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream *destf);
-static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions);
+static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &destf);
+static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions);
static imgtoolerr_t dsk_image_deletefile(imgtool::partition *partition, const char *fpath);
static imgtoolerr_t win_image_deletefile(imgtool::partition *partition, const char *fpath);
-static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions);
-static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions);
+static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
+static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
enum
{
@@ -3995,7 +3995,7 @@ void ti99_ti99hd_get_info(const imgtool_class *imgclass, UINT32 state, union img
/*
Open a file as a ti99_image (common code).
*/
-static int dsk_image_init(imgtool::image *img, imgtool::stream *f, ti99_img_format img_format)
+static int dsk_image_init(imgtool::image *img, imgtool::stream &f, ti99_img_format img_format)
{
struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes();
dsk_vib vib;
@@ -4096,7 +4096,7 @@ static int dsk_image_init(imgtool::image *img, imgtool::stream *f, ti99_img_form
/*
Open a file as a ti99_image (MESS format).
*/
-static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream *f)
+static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream &f)
{
return (imgtoolerr_t)dsk_image_init(image, f, if_mess);
}
@@ -4104,7 +4104,7 @@ static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream *
/*
Open a file as a ti99_image (V9T9 format).
*/
-static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream *f)
+static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream &f)
{
return (imgtoolerr_t)dsk_image_init(image, f, if_v9t9);
}
@@ -4112,7 +4112,7 @@ static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream *
/*
Open a file as a ti99_image (PC99 FM format).
*/
-static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::stream *f)
+static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::stream &f)
{
return (imgtoolerr_t)dsk_image_init(image, f, if_pc99_fm);
}
@@ -4120,7 +4120,7 @@ static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::strea
/*
Open a file as a ti99_image (PC99 MFM format).
*/
-static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stream *f)
+static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stream &f)
{
return (imgtoolerr_t)dsk_image_init(image, f, if_pc99_mfm);
}
@@ -4128,7 +4128,7 @@ static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stre
/*
Open a file as a ti99_image (harddisk format).
*/
-static imgtoolerr_t win_image_init(imgtool::image *img, imgtool::stream *f)
+static imgtoolerr_t win_image_init(imgtool::image *img, imgtool::stream &f)
{
struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes();
win_vib_ddr vib;
@@ -4502,7 +4502,7 @@ static imgtoolerr_t ti99_image_freespace(imgtool::partition *partition, UINT64 *
/*
Extract a file from a ti99_image. The file is saved in tifile format.
*/
-static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &destf)
{
imgtool::image *img = &partition->image();
#if 1
@@ -4574,7 +4574,7 @@ static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const cha
#endif
set_file_update_date(&dst_file, date_time);
- if (destf->write(& dst_file.tifiles.hdr, 128) != 128)
+ if (destf.write(& dst_file.tifiles.hdr, 128) != 128)
return (imgtoolerr_t)IMGTOOLERR_WRITEERROR;
/* copy data to TIFILE */
@@ -4630,9 +4630,9 @@ static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const cha
errorcode = read_next_record(& src_file, buf, & reclen);
if (errorcode)
return errorcode;
- if (destf->write(buf, reclen) != reclen)
+ if (destf.write(buf, reclen) != reclen)
return IMGTOOLERR_WRITEERROR;
- if (destf->write(&lineend, 1) != 1)
+ if (destf.write(&lineend, 1) != 1)
return IMGTOOLERR_WRITEERROR;
}
@@ -4644,7 +4644,7 @@ static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const cha
/*
Add a file to a ti99_image. The file must be in tifile format.
*/
-static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions)
+static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{
imgtool::image *img = &partition->image();
struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes();
@@ -4766,7 +4766,7 @@ static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const ch
/* copy data */
for (i=0; i<fphysrecs; i++)
{
- if (sourcef->read(buf, 256) != 256)
+ if (sourcef.read(buf, 256) != 256)
return (imgtoolerr_t)IMGTOOLERR_READERROR;
errorcode = (imgtoolerr_t)write_file_physrec(& dst_file, i, buf);
@@ -5226,7 +5226,7 @@ static imgtoolerr_t win_image_deletefile(imgtool::partition *partition, const ch
Supports MESS and V9T9 formats only
*/
-static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions, ti99_img_format img_format)
+static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions, ti99_img_format img_format)
{
const char *volname;
int density;
@@ -5241,7 +5241,7 @@ static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool::stream *f,
int i;
l1_img.img_format = img_format;
- l1_img.file_handle = f;
+ l1_img.file_handle = &f;
/* read options */
volname = createoptions->lookup_string(dsk_createopts_volname).c_str();
@@ -5346,7 +5346,7 @@ static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool::stream *f,
/*
Create a blank ti99_image (MESS format).
*/
-static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions)
+static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{
return dsk_image_create(image, f, createoptions, if_mess);
}
@@ -5354,7 +5354,7 @@ static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream
/*
Create a blank ti99_image (V9T9 format).
*/
-static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions)
+static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{
return dsk_image_create(image, f, createoptions, if_v9t9);
}
diff --git a/src/tools/imgtool/modules/ti990hd.cpp b/src/tools/imgtool/modules/ti990hd.cpp
index 57fb01b77e3..d711a1b7eee 100644
--- a/src/tools/imgtool/modules/ti990hd.cpp
+++ b/src/tools/imgtool/modules/ti990hd.cpp
@@ -386,7 +386,7 @@ struct ti990_iterator
};
-static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream *f);
+static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream &f);
static void ti990_image_exit(imgtool::image *img);
static void ti990_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t ti990_image_beginenum(imgtool::directory *enumeration, const char *path);
@@ -398,7 +398,7 @@ static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const ch
static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const char *fpath, imgtool::stream *sourcef, util::option_resolution *writeoptions);
static imgtoolerr_t ti990_image_deletefile(imgtool::partition *partition, const char *fpath);
#endif
-static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions);
+static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
enum
{
@@ -531,7 +531,7 @@ static unsigned phys_address_to_offset(const ti990_phys_sec_address *address, co
dest: pointer to destination buffer
len: length of data to read
*/
-static int read_sector_physical_len(imgtool::stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, void *dest, int len)
+static int read_sector_physical_len(imgtool::stream &file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, void *dest, int len)
{
int reply;
@@ -539,11 +539,11 @@ static int read_sector_physical_len(imgtool::stream *file_handle, const ti990_ph
return 1;
/* seek to sector */
- reply = file_handle->seek(phys_address_to_offset(address, geometry), SEEK_SET);
+ reply = file_handle.seek(phys_address_to_offset(address, geometry), SEEK_SET);
if (reply)
return 1;
/* read it */
- reply = file_handle->read(dest, len);
+ reply = file_handle.read(dest, len);
if (reply != len)
return 1;
@@ -574,7 +574,7 @@ static int read_sector_physical(imgtool::stream *file_handle, const ti990_phys_s
src: pointer to source buffer
len: length of source buffer
*/
-static int write_sector_physical_len(imgtool::stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, const void *src, int len)
+static int write_sector_physical_len(imgtool::stream &file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, const void *src, int len)
{
int reply;
@@ -582,17 +582,17 @@ static int write_sector_physical_len(imgtool::stream *file_handle, const ti990_p
return 1;
/* seek to sector */
- reply = file_handle->seek(phys_address_to_offset(address, geometry), SEEK_SET);
+ reply = file_handle.seek(phys_address_to_offset(address, geometry), SEEK_SET);
if (reply)
return 1;
/* write it */
- reply = file_handle->write(src, len);
+ reply = file_handle.write(src, len);
if (reply != len)
return 1;
/* pad with 0s if needed */
if (len < geometry->bytes_per_sector)
{
- reply = file_handle->fill(0, geometry->bytes_per_sector - len);
+ reply = file_handle.fill(0, geometry->bytes_per_sector - len);
if (reply != geometry->bytes_per_sector - len)
return 1;
@@ -636,7 +636,7 @@ static void log_address_to_phys_address(int secnum, const ti990_geometry *geomet
dest: pointer to destination buffer
len: length of data to read
*/
-static int read_sector_logical_len(imgtool::stream *file_handle, int secnum, const ti990_geometry *geometry, void *dest, int len)
+static int read_sector_logical_len(imgtool::stream &file_handle, int secnum, const ti990_geometry *geometry, void *dest, int len)
{
ti990_phys_sec_address address;
@@ -670,7 +670,7 @@ static int read_sector_logical(imgtool::stream *file_handle, int secnum, const t
src: pointer to source buffer
len: length of source buffer
*/
-static int write_sector_logical_len(imgtool::stream *file_handle, int secnum, const ti990_geometry *geometry, const void *src, int len)
+static int write_sector_logical_len(imgtool::stream &file_handle, int secnum, const ti990_geometry *geometry, const void *src, int len)
{
ti990_phys_sec_address address;
@@ -688,7 +688,7 @@ static int write_sector_logical_len(imgtool::stream *file_handle, int secnum, co
geometry: disk geometry (sectors per track, tracks per side, sides)
dest: pointer to a source buffer of geometry->bytes_per_sector bytes
*/
-static int write_sector_logical(imgtool::stream *file_handle, int secnum, const ti990_geometry *geometry, const void *src)
+static int write_sector_logical(imgtool::stream &file_handle, int secnum, const ti990_geometry *geometry, const void *src)
{
return write_sector_logical_len(file_handle, secnum, geometry, src, geometry->bytes_per_sector);
}
@@ -1106,15 +1106,15 @@ static int qsort_catalog_compare(const void *p1, const void *p2)
/*
Open a file as a ti990_image.
*/
-static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream *f)
+static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream &f)
{
ti990_image *image = (ti990_image *) img->extra_bytes();
disk_image_header header;
int reply;
unsigned totsecs;
- image->file_handle = f;
- reply = f->read(&header, sizeof(header));
+ image->file_handle = &f;
+ reply = f.read(&header, sizeof(header));
if (reply != sizeof(header))
return IMGTOOLERR_READERROR;
@@ -1131,7 +1131,7 @@ static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream *f)
|| (image->geometry.heads > MAX_HEADS)
|| (image->geometry.cylinders > MAX_CYLINDERS)
|| (totsecs < 1)
- || (f->size() != header_len + totsecs*image->geometry.bytes_per_sector))
+ || (f.size() != header_len + totsecs*image->geometry.bytes_per_sector))
{
return IMGTOOLERR_CORRUPTIMAGE;
}
@@ -1195,7 +1195,7 @@ static imgtoolerr_t ti990_image_beginenum(imgtool::directory *enumeration, const
iter->image = image;
- reply = read_sector_logical_len(iter->image->file_handle,
+ reply = read_sector_logical_len(*iter->image->file_handle,
(unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa),
& iter->image->geometry, &dor, sizeof(dor));
@@ -1223,7 +1223,7 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
ent->eof = 0;
while ((iter->level >= 0)
- && (! (reply = read_sector_logical_len(iter->image->file_handle,
+ && (! (reply = read_sector_logical_len(*iter->image->file_handle,
iter->level ? (unsigned) get_UINT16BE(iter->xdr[iter->level-1].fdr.paa) * get_UINT16BE(iter->image->sec0.spa) + (iter->index[iter->level]+1)
: (unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa) + (iter->index[iter->level]+1),
& iter->image->geometry, &iter->xdr[iter->level],
@@ -1276,7 +1276,7 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
ti990_fdr target_fdr;
char buf[9];
- reply = read_sector_logical_len(iter->image->file_handle,
+ reply = read_sector_logical_len(*iter->image->file_handle,
iter->level ? ((unsigned) get_UINT16BE(iter->xdr[iter->level-1].fdr.paa) * get_UINT16BE(iter->image->sec0.spa) + get_UINT16BE(iter->xdr[iter->level].adr.raf))
: ((unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa) + get_UINT16BE(iter->xdr[iter->level].adr.raf)),
& iter->image->geometry, &target_fdr,
@@ -1382,7 +1382,7 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
if (get_UINT16BE(iter->xdr[iter->level].fdr.saa) != 0)
printf("ninou");
- read_sector_logical_len(iter->image->file_handle,
+ read_sector_logical_len(*iter->image->file_handle,
get_UINT16BE(iter->xdr[iter->level].fdr.paa) * get_UINT16BE(iter->image->sec0.spa),
& iter->image->geometry, &dor, sizeof(dor));
@@ -1431,7 +1431,7 @@ static imgtoolerr_t ti990_image_freespace(imgtool::partition *partition, UINT64
sub_adu = 0;
while (adu<totadus)
{
- read_sector_logical_len(image->file_handle, image->sec0.sbm + record, &image->geometry, buf, sizeof(buf));
+ read_sector_logical_len(*image->file_handle, image->sec0.sbm + record, &image->geometry, buf, sizeof(buf));
while ((adu < totadus) && (sub_adu < 2032))
{
@@ -1764,7 +1764,7 @@ static imgtoolerr_t ti990_image_deletefile(imgtool::partition *partition, const
/*
Create a blank ti990_image.
*/
-static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream *f, util::option_resolution *createoptions)
+static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{
//const char *volname;
ti990_geometry geometry;
@@ -1790,7 +1790,7 @@ static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream *f
set_UINT32BE(& header.sectors_per_track, geometry.sectors_per_track);
set_UINT32BE(& header.bytes_per_sector, geometry.bytes_per_sector);
- reply = f->write(&header, sizeof(header));
+ reply = f.write(&header, sizeof(header));
if (reply != sizeof(header))
{
return IMGTOOLERR_WRITEERROR;
diff --git a/src/tools/imgtool/modules/vzdos.cpp b/src/tools/imgtool/modules/vzdos.cpp
index ad49c426700..ccd4248370f 100644
--- a/src/tools/imgtool/modules/vzdos.cpp
+++ b/src/tools/imgtool/modules/vzdos.cpp
@@ -478,7 +478,7 @@ static imgtoolerr_t vzdos_diskimage_freespace(imgtool::partition *partition, UIN
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t vzdos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t vzdos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t ret;
imgtool::image *image = &partition->image();
@@ -514,7 +514,7 @@ static imgtoolerr_t vzdos_diskimage_readfile(imgtool::partition *partition, cons
/* write either DATA_SIZE or the remaining bytes */
towrite = filesize > DATA_SIZE ? DATA_SIZE : filesize;
- if (destf->write(buffer, towrite) != towrite)
+ if (destf.write(buffer, towrite) != towrite)
return IMGTOOLERR_WRITEERROR;
filesize -= DATA_SIZE;
@@ -602,7 +602,7 @@ static imgtoolerr_t vzdos_diskimage_deletefile(imgtool::partition *partition, co
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, imgtool::stream *sourcef, vzdos_dirent *entry)
+static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, imgtool::stream &sourcef, vzdos_dirent *entry)
{
imgtoolerr_t ret;
imgtool::image *img = &partition->image();
@@ -629,11 +629,11 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, i
return ret;
}
- ret = (imgtoolerr_t) sourcef->seek(offset, SEEK_SET);
+ ret = (imgtoolerr_t) sourcef.seek(offset, SEEK_SET);
if (ret) return ret;
/* check if there is enough space */
- filesize = sourcef->size() - offset;
+ filesize = sourcef.size() - offset;
ret = vzdos_diskimage_freespace(partition, &freespace);
if (ret) return ret;
@@ -668,7 +668,7 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, i
/* write data to disk */
while (filesize > 0) {
toread = filesize > DATA_SIZE ? DATA_SIZE : filesize;
- sourcef->read(buffer, toread);
+ sourcef.read(buffer, toread);
filesize -= toread;
@@ -700,7 +700,7 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, i
}
/* create a new file or overwrite a file */
-static imgtoolerr_t vzdos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t vzdos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t ret;
int ftype;
@@ -789,7 +789,7 @@ static imgtoolerr_t vzdos_diskimage_suggesttransfer(imgtool::partition *partitio
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t vzdos_diskimage_create(imgtool::image *img, imgtool::stream *stream, util::option_resolution *opts)
+static imgtoolerr_t vzdos_diskimage_create(imgtool::image *img, imgtool::stream &stream, util::option_resolution *opts)
{
imgtoolerr_t ret;
int track, sector;
@@ -808,7 +808,7 @@ static imgtoolerr_t vzdos_diskimage_create(imgtool::image *img, imgtool::stream
Imgtool vz filter code
*********************************************************************/
-static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *destf)
+static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{
imgtoolerr_t ret;
imgtool::image *image = &partition->image();
@@ -843,7 +843,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const cha
place_integer_le(header, 22, 2, entry.start_address);
/* write header to file */
- destf->write(header, sizeof(header));
+ destf.write(header, sizeof(header));
/* write data to file */
ret = vzdos_diskimage_readfile(partition, filename, "", destf);
@@ -852,7 +852,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const cha
return IMGTOOLERR_SUCCESS;
}
-static imgtoolerr_t vzsnapshot_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *opts)
+static imgtoolerr_t vzsnapshot_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t ret;
int fnameopt;
@@ -860,7 +860,7 @@ static imgtoolerr_t vzsnapshot_writefile(imgtool::partition *partition, const ch
UINT8 header[24];
/* get header infos from file */
- sourcef->read(header, sizeof(header));
+ sourcef.read(header, sizeof(header));
/* prepare directory entry */
entry.ftype = header[21] == 0xF1 ? 'B' : 'T';