mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
more astring -> std::string (nw)
This commit is contained in:
parent
2f095e71f1
commit
7e1f926b94
@ -573,7 +573,7 @@ image_error_t device_image_interface::load_image_by_path(UINT32 open_flags, cons
|
||||
{
|
||||
file_error filerr = FILERR_NOT_FOUND;
|
||||
image_error_t err = IMAGE_ERROR_FILENOTFOUND;
|
||||
astring revised_path;
|
||||
std::string revised_path;
|
||||
|
||||
/* attempt to read the file */
|
||||
filerr = zippath_fopen(path, open_flags, m_file, revised_path);
|
||||
@ -627,7 +627,7 @@ int device_image_interface::reopen_for_write(const char *path)
|
||||
|
||||
file_error filerr = FILERR_NOT_FOUND;
|
||||
image_error_t err = IMAGE_ERROR_FILENOTFOUND;
|
||||
astring revised_path;
|
||||
std::string revised_path;
|
||||
|
||||
/* attempt to open the file for writing*/
|
||||
filerr = zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path);
|
||||
|
@ -280,7 +280,7 @@ protected:
|
||||
astring m_filetype;
|
||||
|
||||
/* working directory; persists across mounts */
|
||||
astring m_working_directory;
|
||||
std::string m_working_directory;
|
||||
|
||||
/* Software information */
|
||||
astring m_full_software_name;
|
||||
|
@ -320,10 +320,10 @@ void floppy_image_device::device_timer(emu_timer &timer, device_timer_id id, int
|
||||
index_resync();
|
||||
}
|
||||
|
||||
floppy_image_format_t *floppy_image_device::identify(astring filename)
|
||||
floppy_image_format_t *floppy_image_device::identify(std::string filename)
|
||||
{
|
||||
core_file *fd;
|
||||
astring revised_path;
|
||||
std::string revised_path;
|
||||
|
||||
file_error err = zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
|
||||
if(err) {
|
||||
@ -862,7 +862,7 @@ ui_menu_control_floppy_image::~ui_menu_control_floppy_image()
|
||||
void ui_menu_control_floppy_image::do_load_create()
|
||||
{
|
||||
floppy_image_device *fd = static_cast<floppy_image_device *>(image);
|
||||
if(input_filename.cmp("")==0) {
|
||||
if(input_filename.compare("")==0) {
|
||||
int err = fd->create(output_filename.c_str(), 0, NULL);
|
||||
if (err != 0) {
|
||||
popmessage("Error: %s", fd->error());
|
||||
@ -871,7 +871,7 @@ void ui_menu_control_floppy_image::do_load_create()
|
||||
fd->setup_write(output_format);
|
||||
} else {
|
||||
int err = fd->load(input_filename.c_str());
|
||||
if(!err && output_filename.cmp("")!=0)
|
||||
if (!err && output_filename.compare("") != 0)
|
||||
err = fd->reopen_for_write(output_filename.c_str());
|
||||
if(err != 0) {
|
||||
popmessage("Error: %s", fd->error());
|
||||
@ -882,7 +882,7 @@ void ui_menu_control_floppy_image::do_load_create()
|
||||
}
|
||||
}
|
||||
|
||||
void ui_menu_control_floppy_image::hook_load(astring filename, bool softlist)
|
||||
void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist)
|
||||
{
|
||||
if (softlist)
|
||||
{
|
||||
@ -905,7 +905,7 @@ void ui_menu_control_floppy_image::hook_load(astring filename, bool softlist)
|
||||
bool can_in_place = input_format->supports_save();
|
||||
if(can_in_place) {
|
||||
file_error filerr = FILERR_NOT_FOUND;
|
||||
astring tmp_path;
|
||||
std::string tmp_path;
|
||||
core_file *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);
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
void set_formats(const floppy_format_type *formats);
|
||||
floppy_image_format_t *get_formats() const;
|
||||
floppy_image_format_t *get_load_format() const;
|
||||
floppy_image_format_t *identify(astring filename);
|
||||
floppy_image_format_t *identify(std::string filename);
|
||||
void set_rpm(float rpm);
|
||||
|
||||
// image-level overrides
|
||||
@ -197,10 +197,10 @@ protected:
|
||||
|
||||
floppy_image_format_t **format_array;
|
||||
floppy_image_format_t *input_format, *output_format;
|
||||
astring input_filename, output_filename;
|
||||
std::string input_filename, output_filename;
|
||||
|
||||
void do_load_create();
|
||||
virtual void hook_load(astring filename, bool softlist);
|
||||
virtual void hook_load(std::string filename, bool softlist);
|
||||
};
|
||||
|
||||
|
||||
|
@ -219,7 +219,7 @@ static int is_valid_filename_char(unicode_char unichar)
|
||||
// ctor
|
||||
//-------------------------------------------------
|
||||
|
||||
ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool *ok)
|
||||
ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok)
|
||||
: ui_menu(machine, container),
|
||||
m_current_directory(current_directory),
|
||||
m_current_file(current_file)
|
||||
@ -257,14 +257,14 @@ void ui_menu_file_create::custom_render(void *selectedref, float top, float bott
|
||||
|
||||
void ui_menu_file_create::populate()
|
||||
{
|
||||
astring buffer;
|
||||
std::string buffer;
|
||||
const image_device_format *format;
|
||||
const char *new_image_name;
|
||||
|
||||
// append the "New Image Name" item
|
||||
if (get_selection() == ITEMREF_NEW_IMAGE_NAME)
|
||||
{
|
||||
buffer.cat(m_filename_buffer).cat("_");
|
||||
buffer.append(m_filename_buffer).append("_");
|
||||
new_image_name = buffer.c_str();
|
||||
}
|
||||
else
|
||||
@ -307,10 +307,10 @@ void ui_menu_file_create::handle()
|
||||
case IPT_UI_SELECT:
|
||||
if ((event->itemref == ITEMREF_CREATE) || (event->itemref == ITEMREF_NEW_IMAGE_NAME))
|
||||
{
|
||||
astring tmp_file(m_filename_buffer);
|
||||
if (tmp_file.find(".") != -1 && tmp_file.find(".") < tmp_file.len() - 1)
|
||||
std::string tmp_file(m_filename_buffer);
|
||||
if (tmp_file.find(".") != -1 && tmp_file.find(".") < tmp_file.length() - 1)
|
||||
{
|
||||
m_current_file.cpy(m_filename_buffer);
|
||||
m_current_file.append(m_filename_buffer);
|
||||
ui_menu::stack_pop(machine());
|
||||
}
|
||||
else
|
||||
@ -344,7 +344,7 @@ void ui_menu_file_create::handle()
|
||||
// ctor
|
||||
//-------------------------------------------------
|
||||
|
||||
ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result)
|
||||
ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result)
|
||||
: ui_menu(machine, container),
|
||||
m_current_directory(current_directory),
|
||||
m_current_file(current_file)
|
||||
@ -456,7 +456,7 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_entry(
|
||||
|
||||
ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent)
|
||||
{
|
||||
astring buffer;
|
||||
std::string buffer;
|
||||
file_selector_entry_type entry_type;
|
||||
file_selector_entry *entry;
|
||||
|
||||
@ -664,13 +664,13 @@ void ui_menu_file_selector::handle()
|
||||
machine().ui().popup_time(1, "Error accessing %s", entry->fullpath);
|
||||
break;
|
||||
}
|
||||
m_current_directory.cpy(entry->fullpath);
|
||||
m_current_directory.assign(entry->fullpath);
|
||||
reset((ui_menu_reset_options)0);
|
||||
break;
|
||||
|
||||
case SELECTOR_ENTRY_TYPE_FILE:
|
||||
// file
|
||||
m_current_file.cpy(entry->fullpath);
|
||||
m_current_file.assign(entry->fullpath);
|
||||
*m_result = R_FILE;
|
||||
ui_menu::stack_pop(machine());
|
||||
break;
|
||||
|
@ -34,7 +34,7 @@ private:
|
||||
class ui_menu_file_create : public ui_menu
|
||||
{
|
||||
public:
|
||||
ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool *ok);
|
||||
ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok);
|
||||
virtual ~ui_menu_file_create();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
@ -42,8 +42,8 @@ public:
|
||||
|
||||
private:
|
||||
device_image_interface * m_image;
|
||||
astring & m_current_directory;
|
||||
astring & m_current_file;
|
||||
std::string & m_current_directory;
|
||||
std::string & m_current_file;
|
||||
const image_device_format * m_current_format;
|
||||
char m_filename_buffer[1024];
|
||||
|
||||
@ -58,7 +58,7 @@ class ui_menu_file_selector : public ui_menu
|
||||
{
|
||||
public:
|
||||
enum { R_EMPTY, R_SOFTLIST, R_CREATE, R_FILE };
|
||||
ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result);
|
||||
ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result);
|
||||
virtual ~ui_menu_file_selector();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
@ -86,8 +86,8 @@ private:
|
||||
|
||||
// internal state
|
||||
device_image_interface * m_image;
|
||||
astring & m_current_directory;
|
||||
astring & m_current_file;
|
||||
std::string & m_current_directory;
|
||||
std::string & m_current_file;
|
||||
bool m_has_empty;
|
||||
bool m_has_softlist;
|
||||
bool m_has_create;
|
||||
|
@ -46,7 +46,7 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach
|
||||
if(swi)
|
||||
{
|
||||
state = START_OTHER_PART;
|
||||
current_directory.cpy(image->working_directory());
|
||||
current_directory.assign(image->working_directory());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -55,14 +55,14 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach
|
||||
/* if the image exists, set the working directory to the parent directory */
|
||||
if (image->exists())
|
||||
{
|
||||
current_file.cpy(image->filename());
|
||||
current_file.assign(image->filename());
|
||||
zippath_parent(current_directory, current_file.c_str());
|
||||
} else
|
||||
current_directory.cpy(image->working_directory());
|
||||
current_directory.assign(image->working_directory());
|
||||
|
||||
/* check to see if the path exists; if not clear it */
|
||||
if (zippath_opendir(current_directory.c_str(), NULL) != FILERR_NONE)
|
||||
current_directory.reset();
|
||||
current_directory.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ ui_menu_control_device_image::~ui_menu_control_device_image()
|
||||
|
||||
void ui_menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
|
||||
{
|
||||
astring path;
|
||||
std::string path;
|
||||
osd_directory_entry *entry;
|
||||
osd_dir_entry_type file_type;
|
||||
|
||||
@ -132,7 +132,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf
|
||||
|
||||
void ui_menu_control_device_image::load_software_part()
|
||||
{
|
||||
astring temp_name = astring(sld->list_name()).cat(":").cat(swi->shortname()).cat(":").cat(swp->name());
|
||||
std::string temp_name = std::string(sld->list_name()).append(":").append(swi->shortname()).append(":").append(swp->name());
|
||||
|
||||
driver_enumerator drivlist(machine().options(), machine().options().system_name());
|
||||
media_auditor auditor(drivlist);
|
||||
@ -152,7 +152,7 @@ void ui_menu_control_device_image::load_software_part()
|
||||
// hook_load
|
||||
//-------------------------------------------------
|
||||
|
||||
void ui_menu_control_device_image::hook_load(astring name, bool softlist)
|
||||
void ui_menu_control_device_image::hook_load(std::string name, bool softlist)
|
||||
{
|
||||
if (image->is_reset_on_load()) image->set_init_phase();
|
||||
image->load(name.c_str());
|
||||
@ -330,7 +330,7 @@ void ui_menu_control_device_image::handle()
|
||||
break;
|
||||
|
||||
case DO_CREATE: {
|
||||
astring path;
|
||||
std::string path;
|
||||
zippath_combine(path, current_directory.c_str(), current_file.c_str());
|
||||
int err = image->create(path.c_str(), 0, NULL);
|
||||
if (err != 0)
|
||||
|
@ -37,11 +37,11 @@ protected:
|
||||
int state;
|
||||
device_image_interface *image;
|
||||
int submenu_result;
|
||||
astring current_directory;
|
||||
astring current_file;
|
||||
std::string current_directory;
|
||||
std::string current_file;
|
||||
|
||||
// methods
|
||||
virtual void hook_load(astring filename, bool softlist);
|
||||
virtual void hook_load(std::string filename, bool softlist);
|
||||
|
||||
bool create_ok;
|
||||
|
||||
@ -52,7 +52,7 @@ private:
|
||||
const software_info *swi;
|
||||
const software_part *swp;
|
||||
class software_list_device *sld;
|
||||
astring software_info_name;
|
||||
std::string software_info_name;
|
||||
|
||||
// methods
|
||||
void test_create(bool &can_create, bool &need_confirm);
|
||||
|
@ -120,7 +120,7 @@ void ui_menu_software_parts::handle()
|
||||
// ctor
|
||||
//-------------------------------------------------
|
||||
|
||||
ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, astring &result)
|
||||
ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, std::string &result)
|
||||
: ui_menu(machine, container), m_result(result)
|
||||
{
|
||||
m_swlist = swlist;
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
|
||||
class ui_menu_software_list : public ui_menu {
|
||||
public:
|
||||
ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, astring &result);
|
||||
ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, std::string &result);
|
||||
virtual ~ui_menu_software_list();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
@ -57,7 +57,7 @@ private:
|
||||
// variables
|
||||
software_list_device * m_swlist; // currently selected list
|
||||
const char * m_interface;
|
||||
astring & m_result;
|
||||
std::string & m_result;
|
||||
entry_info * m_entrylist;
|
||||
char m_filename_buffer[1024];
|
||||
bool m_ordered_by_shortname;
|
||||
|
@ -23,7 +23,7 @@
|
||||
struct zippath_returned_directory
|
||||
{
|
||||
zippath_returned_directory *next;
|
||||
astring name;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
/* specific to ZIP directories */
|
||||
bool called_zip_first;
|
||||
zip_file *zipfile;
|
||||
astring zipprefix;
|
||||
std::string zipprefix;
|
||||
zippath_returned_directory *returned_dirlist;
|
||||
};
|
||||
|
||||
@ -109,13 +109,19 @@ static void parse_parent_path(const char *path, int *beginpos, int *endpos)
|
||||
zippath_parent - retrieves the parent directory
|
||||
-------------------------------------------------*/
|
||||
|
||||
astring &zippath_parent(astring &dst, const char *path)
|
||||
std::string &zippath_parent(std::string &dst, const char *path)
|
||||
{
|
||||
int pos;
|
||||
parse_parent_path(path, &pos, NULL);
|
||||
|
||||
/* return the result */
|
||||
return (pos >= 0) ? dst.cpy(path, pos + 1) : dst.reset();
|
||||
if (pos >= 0) {
|
||||
dst.assign(path, pos + 1);
|
||||
}
|
||||
else {
|
||||
dst.clear();
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
@ -125,12 +131,12 @@ astring &zippath_parent(astring &dst, const char *path)
|
||||
directory basename
|
||||
-------------------------------------------------*/
|
||||
|
||||
astring &zippath_parent_basename(astring &dst, const char *path)
|
||||
std::string &zippath_parent_basename(std::string &dst, const char *path)
|
||||
{
|
||||
int beginpos, endpos;
|
||||
parse_parent_path(path, &beginpos, &endpos);
|
||||
|
||||
return dst.cpy(path + beginpos + 1, endpos - beginpos);
|
||||
dst.copy((char*)(path + beginpos + 1), endpos - beginpos);
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
@ -139,11 +145,11 @@ astring &zippath_parent_basename(astring &dst, const char *path)
|
||||
zippath_combine - combines two paths
|
||||
-------------------------------------------------*/
|
||||
|
||||
astring &zippath_combine(astring &dst, const char *path1, const char *path2)
|
||||
std::string &zippath_combine(std::string &dst, const char *path1, const char *path2)
|
||||
{
|
||||
if (!strcmp(path2, "."))
|
||||
{
|
||||
dst.cpy(path1);
|
||||
dst.assign(path1);
|
||||
}
|
||||
else if (!strcmp(path2, ".."))
|
||||
{
|
||||
@ -151,15 +157,15 @@ astring &zippath_combine(astring &dst, const char *path1, const char *path2)
|
||||
}
|
||||
else if (osd_is_absolute_path(path2))
|
||||
{
|
||||
dst.cpy(path2);
|
||||
dst.assign(path2);
|
||||
}
|
||||
else if ((path1[0] != '\0') && !is_path_separator(path1[strlen(path1) - 1]))
|
||||
{
|
||||
dst.cpy(path1).cat(PATH_SEPARATOR).cat(path2);
|
||||
dst.assign(path1).append(PATH_SEPARATOR).append(path2);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst.cpy(path1).cat(path2);
|
||||
dst.assign(path1).append(path2);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
@ -243,7 +249,7 @@ done:
|
||||
zippath_fopen - opens a zip path file
|
||||
-------------------------------------------------*/
|
||||
|
||||
file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&file, astring &revised_path)
|
||||
file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&file, std::string &revised_path)
|
||||
{
|
||||
file_error filerr = FILERR_NOT_FOUND;
|
||||
zip_error ziperr;
|
||||
@ -254,13 +260,13 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil
|
||||
int len;
|
||||
|
||||
/* first, set up the two types of paths */
|
||||
astring mainpath(filename);
|
||||
astring subpath;
|
||||
std::string mainpath(filename);
|
||||
std::string subpath;
|
||||
file = NULL;
|
||||
|
||||
/* loop through */
|
||||
while((file == NULL) && (mainpath.len() > 0)
|
||||
&& ((openflags == OPEN_FLAG_READ) || (subpath.len() == 0)))
|
||||
while((file == NULL) && (mainpath.length() > 0)
|
||||
&& ((openflags == OPEN_FLAG_READ) || (subpath.length() == 0)))
|
||||
{
|
||||
/* is the mainpath a ZIP path? */
|
||||
if (is_zip_file(mainpath.c_str()))
|
||||
@ -276,7 +282,7 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (subpath.len() > 0)
|
||||
if (subpath.length() > 0)
|
||||
header = zippath_find_sub_path(zip, subpath.c_str(), &entry_type);
|
||||
else
|
||||
header = zip_file_first_file(zip);
|
||||
@ -293,8 +299,8 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil
|
||||
goto done;
|
||||
|
||||
/* update subpath, if appropriate */
|
||||
if (subpath.len() == 0)
|
||||
subpath.cpy(header->filename);
|
||||
if (subpath.length() == 0)
|
||||
subpath.assign(header->filename);
|
||||
|
||||
/* we're done */
|
||||
goto done;
|
||||
@ -306,7 +312,7 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (subpath.len() == 0)
|
||||
if (subpath.length() == 0)
|
||||
filerr = core_fopen(filename, openflags, &file);
|
||||
else
|
||||
filerr = FILERR_NOT_FOUND;
|
||||
@ -315,40 +321,40 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil
|
||||
if (filerr != FILERR_NONE)
|
||||
{
|
||||
/* go up a directory */
|
||||
astring temp;
|
||||
std::string temp;
|
||||
zippath_parent(temp, mainpath.c_str());
|
||||
|
||||
/* append to the sub path */
|
||||
if (subpath.len() > 0)
|
||||
if (subpath.length() > 0)
|
||||
{
|
||||
astring temp2;
|
||||
temp2.cpysubstr(mainpath, temp.len()).cat(PATH_SEPARATOR).cat(subpath);
|
||||
subpath.cpy(temp2);
|
||||
std::string temp2;
|
||||
temp2.assign(mainpath.substr(temp.length()).append(PATH_SEPARATOR).append(subpath));
|
||||
subpath.assign(temp2);
|
||||
}
|
||||
else
|
||||
subpath.cpysubstr(mainpath, temp.len());
|
||||
subpath.assign(mainpath.substr(temp.length()));
|
||||
|
||||
/* get the new main path, truncating path separators */
|
||||
len = temp.len();
|
||||
len = temp.length();
|
||||
while (len > 0 && is_zip_file_separator(temp[len - 1]))
|
||||
len--;
|
||||
mainpath.cpysubstr(temp, 0, len);
|
||||
mainpath.assign(temp.substr(0, len));
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
/* store the revised path */
|
||||
revised_path.reset();
|
||||
revised_path.clear();
|
||||
if (filerr == FILERR_NONE)
|
||||
{
|
||||
/* cannonicalize mainpath */
|
||||
filerr = osd_get_full_path(&alloc_fullpath, mainpath.c_str());
|
||||
if (filerr == FILERR_NONE)
|
||||
{
|
||||
if (subpath.len() > 0)
|
||||
revised_path.cpy(alloc_fullpath).cat(PATH_SEPARATOR).cat(subpath);
|
||||
if (subpath.length() > 0)
|
||||
revised_path.assign(alloc_fullpath).append(PATH_SEPARATOR).append(subpath);
|
||||
else
|
||||
revised_path.cpy(alloc_fullpath);
|
||||
revised_path.assign(alloc_fullpath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,7 +540,7 @@ static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const cha
|
||||
true path and ZIP entry components
|
||||
-------------------------------------------------*/
|
||||
|
||||
static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, zip_file *&zipfile, astring &newpath)
|
||||
static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, zip_file *&zipfile, std::string &newpath)
|
||||
{
|
||||
file_error err;
|
||||
osd_directory_entry *current_entry = NULL;
|
||||
@ -542,21 +548,21 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty
|
||||
int went_up = FALSE;
|
||||
int i;
|
||||
|
||||
newpath.reset();
|
||||
newpath.clear();
|
||||
|
||||
/* be conservative */
|
||||
entry_type = ENTTYPE_NONE;
|
||||
zipfile = NULL;
|
||||
|
||||
astring apath(path);
|
||||
astring apath_trimmed;
|
||||
std::string apath(path);
|
||||
std::string apath_trimmed;
|
||||
do
|
||||
{
|
||||
/* trim the path of trailing path separators */
|
||||
i = apath.len();
|
||||
i = apath.length();
|
||||
while (i > 1 && is_path_separator(apath[i - 1]))
|
||||
i--;
|
||||
apath_trimmed.cpysubstr(apath, 0, i);
|
||||
apath_trimmed.assign(apath.substr(0, i));
|
||||
|
||||
/* stat the path */
|
||||
current_entry = osd_stat(apath_trimmed.c_str());
|
||||
@ -574,8 +580,8 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty
|
||||
/* if we have not found the file or directory, go up */
|
||||
current_entry_type = ENTTYPE_NONE;
|
||||
went_up = TRUE;
|
||||
astring parent;
|
||||
apath.cpy(zippath_parent(parent, apath.c_str()));
|
||||
std::string parent;
|
||||
apath.assign(zippath_parent(parent, apath.c_str()));
|
||||
}
|
||||
}
|
||||
while (current_entry_type == ENTTYPE_NONE && !is_root(apath.c_str()));
|
||||
@ -591,10 +597,10 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty
|
||||
if ((current_entry_type == ENTTYPE_FILE) && is_zip_file(apath_trimmed.c_str())
|
||||
&& (zip_file_open(apath_trimmed.c_str(), &zipfile) == ZIPERR_NONE))
|
||||
{
|
||||
i = strlen(path + apath.len());
|
||||
while (i > 0 && is_zip_path_separator(path[apath.len() + i - 1]))
|
||||
i = strlen(path + apath.length());
|
||||
while (i > 0 && is_zip_path_separator(path[apath.length() + i - 1]))
|
||||
i--;
|
||||
newpath.cpy(path + apath.len(), i);
|
||||
newpath.assign(path + apath.length(), i);
|
||||
|
||||
/* this was a true ZIP path - attempt to identify the type of path */
|
||||
zippath_find_sub_path(zipfile, newpath.c_str(), ¤t_entry_type);
|
||||
@ -612,7 +618,7 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty
|
||||
err = FILERR_NOT_FOUND;
|
||||
goto done;
|
||||
}
|
||||
newpath.cpy(path);
|
||||
newpath.assign(path);
|
||||
}
|
||||
|
||||
/* success! */
|
||||
@ -716,7 +722,7 @@ void zippath_closedir(zippath_directory *directory)
|
||||
static const char *get_relative_path(zippath_directory *directory, const zip_file_header *header)
|
||||
{
|
||||
const char *result = NULL;
|
||||
int len = directory->zipprefix.len();
|
||||
int len = directory->zipprefix.length();
|
||||
|
||||
if ((len <= strlen(header->filename))
|
||||
&& !strncmp(directory->zipprefix.c_str(), header->filename, len))
|
||||
@ -807,7 +813,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory)
|
||||
/* we've found a new directory; add this to returned_dirlist */
|
||||
rdent = new zippath_returned_directory;
|
||||
rdent->next = directory->returned_dirlist;
|
||||
rdent->name.cpy(relpath, separator - relpath);
|
||||
rdent->name.assign(relpath, separator - relpath);
|
||||
directory->returned_dirlist = rdent;
|
||||
|
||||
/* ...and return it */
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define __ZIPPATH_H__
|
||||
|
||||
#include "corefile.h"
|
||||
#include "astring.h"
|
||||
#include <string>
|
||||
#include "unzip.h"
|
||||
|
||||
|
||||
@ -31,19 +31,19 @@ class zippath_directory;
|
||||
/* ----- path operations ----- */
|
||||
|
||||
/* retrieves the parent directory */
|
||||
astring &zippath_parent(astring &dst, const char *path);
|
||||
std::string &zippath_parent(std::string &dst, const char *path);
|
||||
|
||||
/* retrieves the parent directory basename */
|
||||
astring &zippath_parent_basename(astring &dst, const char *path);
|
||||
std::string &zippath_parent_basename(std::string &dst, const char *path);
|
||||
|
||||
/* combines two paths */
|
||||
astring &zippath_combine(astring &dst, const char *path1, const char *path2);
|
||||
std::string &zippath_combine(std::string &dst, const char *path1, const char *path2);
|
||||
|
||||
|
||||
/* ----- file operations ----- */
|
||||
|
||||
/* opens a zip path file */
|
||||
file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&file, astring &revised_path);
|
||||
file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&file, std::string &revised_path);
|
||||
|
||||
|
||||
/* ----- directory operations ----- */
|
||||
|
Loading…
Reference in New Issue
Block a user