mirror of
https://github.com/holub/mame
synced 2025-06-21 19:56:53 +03:00
Converted a number of zippath calls that took 'const char *' to std::string
This commit is contained in:
parent
c11997af03
commit
bf111bbc6e
@ -363,7 +363,7 @@ floppy_image_format_t *floppy_image_device::identify(std::string filename)
|
|||||||
util::core_file::ptr fd;
|
util::core_file::ptr fd;
|
||||||
std::string revised_path;
|
std::string revised_path;
|
||||||
|
|
||||||
osd_file::error err = util::zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
|
osd_file::error err = util::zippath_fopen(filename, OPEN_FLAG_READ, fd, revised_path);
|
||||||
if(err != osd_file::error::NONE) {
|
if(err != osd_file::error::NONE) {
|
||||||
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to open the image file");
|
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to open the image file");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -350,7 +350,7 @@ bool device_image_interface::try_change_working_directory(const char *subdir)
|
|||||||
|
|
||||||
// did we successfully identify the directory?
|
// did we successfully identify the directory?
|
||||||
if (success)
|
if (success)
|
||||||
m_working_directory = util::zippath_combine(m_working_directory.c_str(), subdir);
|
m_working_directory = util::zippath_combine(m_working_directory, subdir);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -652,7 +652,7 @@ image_error_t device_image_interface::load_image_by_path(UINT32 open_flags, cons
|
|||||||
std::string revised_path;
|
std::string revised_path;
|
||||||
|
|
||||||
// attempt to read the file
|
// attempt to read the file
|
||||||
auto const filerr = util::zippath_fopen(path.c_str(), open_flags, m_file, revised_path);
|
auto const filerr = util::zippath_fopen(path, open_flags, m_file, revised_path);
|
||||||
|
|
||||||
// did the open succeed?
|
// did the open succeed?
|
||||||
switch(filerr)
|
switch(filerr)
|
||||||
|
@ -228,7 +228,7 @@ menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry
|
|||||||
}
|
}
|
||||||
|
|
||||||
// determine the full path
|
// determine the full path
|
||||||
buffer = util::zippath_combine(m_current_directory.c_str(), dirent->name);
|
buffer = util::zippath_combine(m_current_directory, dirent->name);
|
||||||
|
|
||||||
// create the file selector entry
|
// create the file selector entry
|
||||||
entry = &append_entry(
|
entry = &append_entry(
|
||||||
@ -296,10 +296,9 @@ void menu_file_selector::populate()
|
|||||||
const file_selector_entry *selected_entry = nullptr;
|
const file_selector_entry *selected_entry = nullptr;
|
||||||
int i;
|
int i;
|
||||||
const char *volume_name;
|
const char *volume_name;
|
||||||
const char *path = m_current_directory.c_str();
|
|
||||||
|
|
||||||
// open the directory
|
// open the directory
|
||||||
err = util::zippath_opendir(path, &directory);
|
err = util::zippath_opendir(m_current_directory, &directory);
|
||||||
|
|
||||||
// clear out the menu entries
|
// clear out the menu entries
|
||||||
m_entrylist.clear();
|
m_entrylist.clear();
|
||||||
@ -409,7 +408,7 @@ void menu_file_selector::handle()
|
|||||||
case SELECTOR_ENTRY_TYPE_DRIVE:
|
case SELECTOR_ENTRY_TYPE_DRIVE:
|
||||||
case SELECTOR_ENTRY_TYPE_DIRECTORY:
|
case SELECTOR_ENTRY_TYPE_DIRECTORY:
|
||||||
// drive/directory - first check the path
|
// drive/directory - first check the path
|
||||||
err = util::zippath_opendir(entry->fullpath.c_str(), nullptr);
|
err = util::zippath_opendir(entry->fullpath, nullptr);
|
||||||
if (err != osd_file::error::NONE)
|
if (err != osd_file::error::NONE)
|
||||||
{
|
{
|
||||||
// this path is problematic; present the user with an error and bail
|
// this path is problematic; present the user with an error and bail
|
||||||
|
@ -87,7 +87,7 @@ void menu_control_floppy_image::hook_load(std::string filename, bool softlist)
|
|||||||
std::string tmp_path;
|
std::string tmp_path;
|
||||||
util::core_file::ptr tmp_file;
|
util::core_file::ptr tmp_file;
|
||||||
// attempt to open the file for writing but *without* create
|
// attempt to open the file for writing but *without* create
|
||||||
filerr = util::zippath_fopen(filename.c_str(), OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
|
filerr = util::zippath_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
|
||||||
if(filerr == osd_file::error::NONE)
|
if(filerr == osd_file::error::NONE)
|
||||||
tmp_file.reset();
|
tmp_file.reset();
|
||||||
else
|
else
|
||||||
@ -131,7 +131,7 @@ void menu_control_floppy_image::handle()
|
|||||||
m_state = START_FILE;
|
m_state = START_FILE;
|
||||||
handle();
|
handle();
|
||||||
} else {
|
} else {
|
||||||
output_filename = util::zippath_combine(m_current_directory.c_str(), m_current_file.c_str());
|
output_filename = util::zippath_combine(m_current_directory, m_current_file);
|
||||||
output_format = format_array[m_submenu_result.i];
|
output_format = format_array[m_submenu_result.i];
|
||||||
do_load_create();
|
do_load_create();
|
||||||
stack_pop();
|
stack_pop();
|
||||||
|
@ -69,7 +69,7 @@ menu_control_device_image::menu_control_device_image(mame_ui_manager &mui, rende
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check to see if the path exists; if not clear it
|
// check to see if the path exists; if not clear it
|
||||||
if (util::zippath_opendir(m_current_directory.c_str(), nullptr) != osd_file::error::NONE)
|
if (util::zippath_opendir(m_current_directory, nullptr) != osd_file::error::NONE)
|
||||||
m_current_directory.clear();
|
m_current_directory.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ menu_control_device_image::~menu_control_device_image()
|
|||||||
void menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
|
void menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
|
||||||
{
|
{
|
||||||
// assemble the full path
|
// assemble the full path
|
||||||
auto path = util::zippath_combine(m_current_directory.c_str(), m_current_file.c_str());
|
auto path = util::zippath_combine(m_current_directory, m_current_file);
|
||||||
|
|
||||||
// does a file or a directory exist at the path
|
// does a file or a directory exist at the path
|
||||||
auto entry = osd_stat(path.c_str());
|
auto entry = osd_stat(path.c_str());
|
||||||
|
@ -111,9 +111,9 @@ int is_path_separator(char c)
|
|||||||
* @param [in,out] endpos If non-null, the endpos.
|
* @param [in,out] endpos If non-null, the endpos.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void parse_parent_path(const char *path, int *beginpos, int *endpos)
|
static void parse_parent_path(const std::string &path, int *beginpos, int *endpos)
|
||||||
{
|
{
|
||||||
int length = strlen(path);
|
auto length = path.length();
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
/* skip over trailing path separators */
|
/* skip over trailing path separators */
|
||||||
@ -140,13 +140,13 @@ static void parse_parent_path(const char *path, int *beginpos, int *endpos)
|
|||||||
// zippath_parent - retrieves the parent directory
|
// zippath_parent - retrieves the parent directory
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
std::string &zippath_parent(std::string &dst, const char *path)
|
std::string &zippath_parent(std::string &dst, const std::string &path)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
parse_parent_path(path, &pos, nullptr);
|
parse_parent_path(path, &pos, nullptr);
|
||||||
|
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
dst.assign(path, pos + 1);
|
dst = path.substr(0, pos + 1);
|
||||||
else
|
else
|
||||||
dst.clear();
|
dst.clear();
|
||||||
return dst;
|
return dst;
|
||||||
@ -158,7 +158,7 @@ std::string &zippath_parent(std::string &dst, const char *path)
|
|||||||
// zippath_parent - retrieves the parent directory
|
// zippath_parent - retrieves the parent directory
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
std::string zippath_parent(const char *path)
|
std::string zippath_parent(const std::string &path)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
zippath_parent(result, path);
|
zippath_parent(result, path);
|
||||||
@ -173,7 +173,7 @@ std::string zippath_parent(const char *path)
|
|||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn std::string &zippath_parent_basename(std::string &dst, const char *path)
|
* @fn std::string &zippath_parent_basename(std::string &dst, const std::string &path)
|
||||||
*
|
*
|
||||||
* @brief Zippath parent basename.
|
* @brief Zippath parent basename.
|
||||||
*
|
*
|
||||||
@ -183,11 +183,11 @@ std::string zippath_parent(const char *path)
|
|||||||
* @return A std::string&
|
* @return A std::string&
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::string &zippath_parent_basename(std::string &dst, const char *path)
|
std::string &zippath_parent_basename(std::string &dst, const std::string &path)
|
||||||
{
|
{
|
||||||
int beginpos, endpos;
|
int beginpos, endpos;
|
||||||
parse_parent_path(path, &beginpos, &endpos);
|
parse_parent_path(path, &beginpos, &endpos);
|
||||||
dst.copy((char*)(path + beginpos + 1), endpos - beginpos);
|
dst.copy((char*)(path.c_str() + beginpos + 1), endpos - beginpos);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ std::string &zippath_parent_basename(std::string &dst, const char *path)
|
|||||||
// directory basename
|
// directory basename
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
std::string zippath_parent_basename(const char *path)
|
std::string zippath_parent_basename(const std::string &path)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
zippath_parent_basename(result, path);
|
zippath_parent_basename(result, path);
|
||||||
@ -223,13 +223,13 @@ std::string zippath_parent_basename(const char *path)
|
|||||||
* @return A std::string&
|
* @return A std::string&
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::string &zippath_combine(std::string &dst, const char *path1, const char *path2)
|
std::string &zippath_combine(std::string &dst, const std::string &path1, const std::string &path2)
|
||||||
{
|
{
|
||||||
if (!strcmp(path2, "."))
|
if (path2 == ".")
|
||||||
{
|
{
|
||||||
dst.assign(path1);
|
dst.assign(path1);
|
||||||
}
|
}
|
||||||
else if (!strcmp(path2, ".."))
|
else if (path2 == "..")
|
||||||
{
|
{
|
||||||
dst = zippath_parent(path1);
|
dst = zippath_parent(path1);
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ std::string &zippath_combine(std::string &dst, const char *path1, const char *pa
|
|||||||
{
|
{
|
||||||
dst.assign(path2);
|
dst.assign(path2);
|
||||||
}
|
}
|
||||||
else if ((path1[0] != '\0') && !is_path_separator(path1[strlen(path1) - 1]))
|
else if ((path1[0] != '\0') && !is_path_separator(path1[path1.length() - 1]))
|
||||||
{
|
{
|
||||||
dst.assign(path1).append(PATH_SEPARATOR).append(path2);
|
dst.assign(path1).append(PATH_SEPARATOR).append(path2);
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ std::string &zippath_combine(std::string &dst, const char *path1, const char *pa
|
|||||||
// zippath_combine - combines two paths
|
// zippath_combine - combines two paths
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
std::string zippath_combine(const char *path1, const char *path2)
|
std::string zippath_combine(const std::string &path1, const std::string &path2)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
zippath_combine(result, path1, path2);
|
zippath_combine(result, path1, path2);
|
||||||
@ -363,7 +363,7 @@ done:
|
|||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path)
|
* @fn osd_file::error zippath_fopen(const std::string &filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path)
|
||||||
*
|
*
|
||||||
* @brief Zippath fopen.
|
* @brief Zippath fopen.
|
||||||
*
|
*
|
||||||
@ -375,7 +375,7 @@ done:
|
|||||||
* @return A osd_file::error.
|
* @return A osd_file::error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path)
|
osd_file::error zippath_fopen(const std::string &filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path)
|
||||||
{
|
{
|
||||||
osd_file::error filerr = osd_file::error::NOT_FOUND;
|
osd_file::error filerr = osd_file::error::NOT_FOUND;
|
||||||
archive_file::error ziperr;
|
archive_file::error ziperr;
|
||||||
@ -441,7 +441,7 @@ osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core
|
|||||||
if (filerr != osd_file::error::NONE)
|
if (filerr != osd_file::error::NONE)
|
||||||
{
|
{
|
||||||
/* go up a directory */
|
/* go up a directory */
|
||||||
auto temp = zippath_parent(mainpath.c_str());
|
auto temp = zippath_parent(mainpath);
|
||||||
|
|
||||||
/* append to the sub path */
|
/* append to the sub path */
|
||||||
if (subpath.length() > 0)
|
if (subpath.length() > 0)
|
||||||
@ -753,7 +753,7 @@ static osd_file::error zippath_resolve(const char *path, osd::directory::entry::
|
|||||||
// if we have not found the file or directory, go up
|
// if we have not found the file or directory, go up
|
||||||
current_entry_type = osd::directory::entry::entry_type::NONE;
|
current_entry_type = osd::directory::entry::entry_type::NONE;
|
||||||
went_up = true;
|
went_up = true;
|
||||||
apath = zippath_parent(apath.c_str());
|
apath = zippath_parent(apath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((current_entry_type == osd::directory::entry::entry_type::NONE) && !is_root(apath.c_str()));
|
while ((current_entry_type == osd::directory::entry::entry_type::NONE) && !is_root(apath.c_str()));
|
||||||
@ -797,7 +797,7 @@ static osd_file::error zippath_resolve(const char *path, osd::directory::entry::
|
|||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
* @fn osd_file::error zippath_opendir(const std::string &path, zippath_directory **directory)
|
||||||
*
|
*
|
||||||
* @brief Zippath opendir.
|
* @brief Zippath opendir.
|
||||||
*
|
*
|
||||||
@ -807,7 +807,7 @@ static osd_file::error zippath_resolve(const char *path, osd::directory::entry::
|
|||||||
* @return A osd_file::error.
|
* @return A osd_file::error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
osd_file::error zippath_opendir(const std::string &path, zippath_directory **directory)
|
||||||
{
|
{
|
||||||
osd_file::error err;
|
osd_file::error err;
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
|||||||
}
|
}
|
||||||
/* resolve the path */
|
/* resolve the path */
|
||||||
osd::directory::entry::entry_type entry_type;
|
osd::directory::entry::entry_type entry_type;
|
||||||
err = zippath_resolve(path, entry_type, result->zipfile, result->zipprefix);
|
err = zippath_resolve(path.c_str(), entry_type, result->zipfile, result->zipprefix);
|
||||||
if (err != osd_file::error::NONE)
|
if (err != osd_file::error::NONE)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
@ -847,7 +847,7 @@ osd_file::error zippath_opendir(const char *path, zippath_directory **directory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* is this path the root? if so, pretend we've already returned the parent */
|
/* is this path the root? if so, pretend we've already returned the parent */
|
||||||
if (is_root(path))
|
if (is_root(path.c_str()))
|
||||||
result->returned_parent = true;
|
result->returned_parent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,28 +34,28 @@ class zippath_directory;
|
|||||||
// ----- path operations -----
|
// ----- path operations -----
|
||||||
|
|
||||||
// retrieves the parent directory
|
// retrieves the parent directory
|
||||||
std::string &zippath_parent(std::string &dst, const char *path);
|
std::string &zippath_parent(std::string &dst, const std::string &path);
|
||||||
std::string zippath_parent(const char *path);
|
std::string zippath_parent(const std::string &path);
|
||||||
|
|
||||||
// retrieves the parent directory basename
|
// retrieves the parent directory basename
|
||||||
std::string &zippath_parent_basename(std::string &dst, const char *path);
|
std::string &zippath_parent_basename(std::string &dst, const std::string &path);
|
||||||
std::string zippath_parent_basename(const char *path);
|
std::string zippath_parent_basename(const std::string &path);
|
||||||
|
|
||||||
// combines two paths
|
// combines two paths
|
||||||
std::string &zippath_combine(std::string &dst, const char *path1, const char *path2);
|
std::string &zippath_combine(std::string &dst, const std::string &path1, const std::string &path2);
|
||||||
std::string zippath_combine(const char *path1, const char *path2);
|
std::string zippath_combine(const std::string &path1, const std::string &path2);
|
||||||
|
|
||||||
|
|
||||||
// ----- file operations -----
|
// ----- file operations -----
|
||||||
|
|
||||||
// opens a zip path file
|
// opens a zip path file
|
||||||
osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path);
|
osd_file::error zippath_fopen(const std::string &filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path);
|
||||||
|
|
||||||
|
|
||||||
// ----- directory operations ----- */
|
// ----- directory operations ----- */
|
||||||
|
|
||||||
// opens a directory
|
// opens a directory
|
||||||
osd_file::error zippath_opendir(const char *path, zippath_directory **directory);
|
osd_file::error zippath_opendir(const std::string &path, zippath_directory **directory);
|
||||||
|
|
||||||
// closes a directory
|
// closes a directory
|
||||||
void zippath_closedir(zippath_directory *directory);
|
void zippath_closedir(zippath_directory *directory);
|
||||||
|
Loading…
Reference in New Issue
Block a user