summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2016-06-24 07:39:37 -0400
committer Nathan Woods <npwoods@mess.org>2016-06-24 07:39:37 -0400
commit4ddfc6a6e4b8195b001dca2f574b7ab348e704ab (patch)
treec1454ff2bc6387cedf96badbe8188d58a9d780c1
parentcd8b414e6bc14b375dcf2a4eb17eb0353926474f (diff)
Changed osd_stat() to return std::unique_ptr<osd::directory::entry>
-rw-r--r--src/frontend/mame/ui/imgcntrl.cpp6
-rw-r--r--src/lib/util/zippath.cpp2
-rw-r--r--src/osd/modules/file/winfile.cpp6
-rw-r--r--src/osd/osdcore.h3
4 files changed, 6 insertions, 11 deletions
diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp
index 503ad86c0e3..3468fa04b2d 100644
--- a/src/frontend/mame/ui/imgcntrl.cpp
+++ b/src/frontend/mame/ui/imgcntrl.cpp
@@ -88,14 +88,13 @@ menu_control_device_image::~menu_control_device_image()
void menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
{
std::string path;
- osd::directory::entry *entry;
osd::directory::entry::entry_type file_type;
/* assemble the full path */
util::zippath_combine(path, current_directory.c_str(), current_file.c_str());
/* does a file or a directory exist at the path */
- entry = osd_stat(path.c_str());
+ auto entry = osd_stat(path.c_str());
file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE;
switch(file_type)
@@ -124,9 +123,6 @@ void menu_control_device_image::test_create(bool &can_create, bool &need_confirm
need_confirm = false;
fatalerror("Unexpected\n");
}
-
- if (entry != nullptr)
- osd_free(entry);
}
diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp
index 3ee724a4b01..48a919a8cad 100644
--- a/src/lib/util/zippath.cpp
+++ b/src/lib/util/zippath.cpp
@@ -701,7 +701,7 @@ static osd_file::error zippath_resolve(const char *path, osd::directory::entry::
apath_trimmed = apath;
// stat the path
- std::unique_ptr<osd::directory::entry, void (*)(void *)> current_entry(osd_stat(apath_trimmed), &osd_free);
+ auto current_entry = osd_stat(apath_trimmed);
// did we find anything?
if (current_entry)
diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp
index dc22d37096c..bd70fb95eda 100644
--- a/src/osd/modules/file/winfile.cpp
+++ b/src/osd/modules/file/winfile.cpp
@@ -354,7 +354,7 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN
// osd_stat
//============================================================
-osd::directory::entry *osd_stat(const std::string &path)
+std::unique_ptr<osd::directory::entry> osd_stat(const std::string &path)
{
// convert the path to TCHARs
std::unique_ptr<TCHAR, void (*)(void *)> const t_path(tstring_from_utf8(path.c_str()), &osd_free);
@@ -381,7 +381,7 @@ osd::directory::entry *osd_stat(const std::string &path)
// create an osd::directory::entry; be sure to make sure that the caller can
// free all resources by just freeing the resulting osd::directory::entry
- osd::directory::entry *const result = (osd::directory::entry *)osd_malloc_array(sizeof(*result) + path.length() + 1);
+ osd::directory::entry *result = (osd::directory::entry *) operator new(sizeof(*result) + path.length() + 1);
if (!result)
return nullptr;
strcpy(((char *) result) + sizeof(*result), path.c_str());
@@ -390,7 +390,7 @@ osd::directory::entry *osd_stat(const std::string &path)
result->size = find_data.nFileSizeLow | ((UINT64) find_data.nFileSizeHigh << 32);
result->last_modified = win_time_point_from_filetime(&find_data.ftLastWriteTime);
- return result;
+ return std::unique_ptr<osd::directory::entry>(result);
}
diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h
index 85672445196..137f49d58e9 100644
--- a/src/osd/osdcore.h
+++ b/src/osd/osdcore.h
@@ -789,10 +789,9 @@ char *osd_get_clipboard_text(void);
an allocated pointer to an osd::directory::entry representing
info on the path; even if the file does not exist.
- free with osd_free()
-----------------------------------------------------------------------------*/
-osd::directory::entry *osd_stat(std::string const &path);
+std::unique_ptr<osd::directory::entry> osd_stat(std::string const &path);
/***************************************************************************
PATH INTERFACES