summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/imagedev
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2016-03-06 18:02:37 +1100
committer Vas Crabb <vas@vastheman.com>2016-03-06 21:49:56 +1100
commit73b44c94291c4d086477167a76fd7db239936c3b (patch)
tree9af214e443878f4b1e6452d63393ca9f9f8a0884 /src/devices/imagedev
parent00941faaab99d937a32bce4d225ec56951d21020 (diff)
Turn core_file into a proper class that gets cleaned up safely using unique_ptr
Subverted somewhat by chd_file class
Diffstat (limited to 'src/devices/imagedev')
-rw-r--r--src/devices/imagedev/chd_cd.cpp2
-rw-r--r--src/devices/imagedev/diablo.cpp6
-rw-r--r--src/devices/imagedev/floppy.cpp15
-rw-r--r--src/devices/imagedev/harddriv.cpp6
4 files changed, 15 insertions, 14 deletions
diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp
index d9ab295dfad..630403001ff 100644
--- a/src/devices/imagedev/chd_cd.cpp
+++ b/src/devices/imagedev/chd_cd.cpp
@@ -109,7 +109,7 @@ bool cdrom_image_device::call_load()
if (software_entry() == nullptr)
{
if (strstr(m_image_name.c_str(), ".chd") && is_loaded()) {
- err = m_self_chd.open( *image_core_file() ); /* CDs are never writeable */
+ err = m_self_chd.open( image_core_file() ); /* CDs are never writeable */
if ( err )
goto error;
chd = &m_self_chd;
diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp
index f9d4218856a..6ba6aad5cf2 100644
--- a/src/devices/imagedev/diablo.cpp
+++ b/src/devices/imagedev/diablo.cpp
@@ -124,7 +124,7 @@ bool diablo_image_device::call_create(int create_format, option_resolution *crea
/* create the CHD file */
chd_codec_type compression[4] = { CHD_CODEC_NONE };
- err = m_origchd.create(*image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, sectorsize, compression);
+ err = m_origchd.create(image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, sectorsize, compression);
if (err != CHDERR_NONE)
goto error;
@@ -219,14 +219,14 @@ int diablo_image_device::internal_load_dsk()
}
else
{
- err = m_origchd.open(*image_core_file(), true);
+ err = m_origchd.open(image_core_file(), true);
if (err == CHDERR_NONE)
{
m_chd = &m_origchd;
}
else if (err == CHDERR_FILE_NOT_WRITEABLE)
{
- err = m_origchd.open(*image_core_file(), false);
+ err = m_origchd.open(image_core_file(), false);
if (err == CHDERR_NONE)
{
err = open_disk_diff(device().machine().options(), basename_noext(), m_origchd, m_diffchd);
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp
index cb7e184f811..9a2bd21d764 100644
--- a/src/devices/imagedev/floppy.cpp
+++ b/src/devices/imagedev/floppy.cpp
@@ -295,7 +295,7 @@ void floppy_image_device::commit_image()
io.procs = &image_ioprocs;
io.filler = 0xff;
- file_error err = core_truncate(image_core_file(), 0);
+ file_error err = image_core_file().truncate(0);
if (err != 0)
popmessage("Error, unable to truncate image: %d", err);
@@ -362,7 +362,7 @@ void floppy_image_device::device_timer(emu_timer &timer, device_timer_id id, int
floppy_image_format_t *floppy_image_device::identify(std::string filename)
{
- core_file *fd;
+ util::core_file::ptr fd;
std::string revised_path;
file_error err = zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
@@ -372,19 +372,20 @@ floppy_image_format_t *floppy_image_device::identify(std::string filename)
}
io_generic io;
- io.file = fd;
+ io.file = fd.get();
io.procs = &corefile_ioprocs_noclose;
io.filler = 0xff;
int best = 0;
floppy_image_format_t *best_format = nullptr;
- for(floppy_image_format_t *format = fif_list; format; format = format->next) {
+ for (floppy_image_format_t *format = fif_list; format; format = format->next)
+ {
int score = format->identify(&io, form_factor);
if(score > best) {
best = score;
best_format = format;
}
}
- core_fclose(fd);
+ fd.reset();
return best_format;
}
@@ -1001,11 +1002,11 @@ void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist
if(can_in_place) {
file_error filerr;
std::string tmp_path;
- core_file *tmp_file;
+ util::core_file::ptr tmp_file;
/* attempt to open the file for writing but *without* create */
filerr = zippath_fopen(filename.c_str(), OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
if(!filerr)
- core_fclose(tmp_file);
+ tmp_file.reset();
else
can_in_place = false;
}
diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp
index c03b0e4075b..d07852e166f 100644
--- a/src/devices/imagedev/harddriv.cpp
+++ b/src/devices/imagedev/harddriv.cpp
@@ -148,7 +148,7 @@ bool harddisk_image_device::call_create(int create_format, option_resolution *cr
/* create the CHD file */
chd_codec_type compression[4] = { CHD_CODEC_NONE };
- err = m_origchd.create(*image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, sectorsize, compression);
+ err = m_origchd.create(image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, sectorsize, compression);
if (err != CHDERR_NONE)
goto error;
@@ -243,14 +243,14 @@ int harddisk_image_device::internal_load_hd()
}
else
{
- err = m_origchd.open(*image_core_file(), true);
+ err = m_origchd.open(image_core_file(), true);
if (err == CHDERR_NONE)
{
m_chd = &m_origchd;
}
else if (err == CHDERR_FILE_NOT_WRITEABLE)
{
- err = m_origchd.open(*image_core_file(), false);
+ err = m_origchd.open(image_core_file(), false);
if (err == CHDERR_NONE)
{
err = open_disk_diff(device().machine().options(), basename_noext(), m_origchd, m_diffchd);