diff options
Diffstat (limited to 'src/emu/fileio.c')
-rw-r--r-- | src/emu/fileio.c | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/src/emu/fileio.c b/src/emu/fileio.c index a19368d7065..68efdb021a3 100644 --- a/src/emu/fileio.c +++ b/src/emu/fileio.c @@ -39,7 +39,7 @@ path_iterator::path_iterator(const char *rawsearchpath) // in a multipath sequence //------------------------------------------------- -bool path_iterator::next(astring &buffer, const char *name) +bool path_iterator::next(std::string &buffer, const char *name) { // if none left, return FALSE to indicate we are done if (m_index != 0 && *m_current == 0) @@ -49,16 +49,16 @@ bool path_iterator::next(astring &buffer, const char *name) const char *semi = strchr(m_current, ';'); if (semi == NULL) semi = m_current + strlen(m_current); - buffer.cpy(m_current, semi - m_current); + buffer.assign(m_current, semi - m_current); m_current = (*semi == 0) ? semi : semi + 1; // append the name if we have one if (name != NULL) { // compute the full pathname - if (buffer.len() > 0) - buffer.cat(PATH_SEPARATOR); - buffer.cat(name); + if (buffer.length() > 0) + buffer.append(PATH_SEPARATOR); + buffer.append(name); } // bump the index and return TRUE @@ -219,17 +219,17 @@ emu_file::operator core_file &() hash_collection &emu_file::hashes(const char *types) { // determine the hashes we already have - astring already_have; + std::string already_have; m_hashes.hash_types(already_have); // determine which hashes we need - astring needed; + std::string needed; for (const char *scan = types; *scan != 0; scan++) - if (already_have.chr(0, *scan) == -1) - needed.cat(*scan); + if (already_have.find_first_of(*scan) == -1) + needed.push_back(*scan); // if we need nothing, skip it - if (!needed) + if (needed.empty()) return m_hashes; // load the ZIP file if needed @@ -281,21 +281,21 @@ file_error emu_file::open(const char *name) file_error emu_file::open(const char *name1, const char *name2) { // concatenate the strings and do a standard open - astring name = astring(name1).cat(name2); + std::string name = std::string(name1).append(name2); return open(name.c_str()); } file_error emu_file::open(const char *name1, const char *name2, const char *name3) { // concatenate the strings and do a standard open - astring name = astring(name1).cat(name2).cat(name3); + std::string name = std::string(name1).append(name2).append(name3); return open(name.c_str()); } file_error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4) { // concatenate the strings and do a standard open - astring name = astring(name1).cat(name2).cat(name3).cat(name4); + std::string name = std::string(name1).append(name2).append(name3).append(name4); return open(name.c_str()); } @@ -314,21 +314,21 @@ file_error emu_file::open(const char *name, UINT32 crc) file_error emu_file::open(const char *name1, const char *name2, UINT32 crc) { // concatenate the strings and do a standard open - astring name = astring(name1).cat(name2); + std::string name = std::string(name1).append(name2); return open(name.c_str(), crc); } file_error emu_file::open(const char *name1, const char *name2, const char *name3, UINT32 crc) { // concatenate the strings and do a standard open - astring name = astring(name1).cat(name2).cat(name3); + std::string name = std::string(name1).append(name2).append(name3); return open(name.c_str(), crc); } file_error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4, UINT32 crc) { // concatenate the strings and do a standard open - astring name = astring(name1).cat(name2).cat(name3).cat(name4); + std::string name = std::string(name1).append(name2).append(name3).append(name4); return open(name.c_str(), crc); } @@ -356,7 +356,7 @@ file_error emu_file::open_next() // if we're opening for read-only we have other options if ((m_openflags & (OPEN_FLAG_READ | OPEN_FLAG_WRITE)) == OPEN_FLAG_READ) { - astring tempfullpath = m_fullpath; + std::string tempfullpath = m_fullpath; filerr = attempt_zipped(); if (filerr == FILERR_NONE) @@ -418,7 +418,7 @@ void emu_file::close() // reset our hashes and path as well m_hashes.reset(); - m_fullpath.reset(); + m_fullpath.clear(); } @@ -657,14 +657,15 @@ int emu_file::vprintf(const char *fmt, va_list va) // any media path //------------------------------------------------- -bool emu_file::part_of_mediapath(astring path) +bool emu_file::part_of_mediapath(std::string path) { bool result = false; - astring mediapath; + std::string mediapath; m_mediapaths.reset(); - while (m_mediapaths.next(mediapath, NULL) && !result) - if (path.cmpsubstr(mediapath, 0, mediapath.len())) + while (m_mediapaths.next(mediapath, NULL) && !result) { + if (path.compare(mediapath.substr(0, mediapath.length()))) result = true; + } return result; } @@ -674,13 +675,13 @@ bool emu_file::part_of_mediapath(astring path) file_error emu_file::attempt_zipped() { - astring filename; + std::string filename; // loop over directory parts up to the start of filename while (1) { // find the final path separator - int dirsep = m_fullpath.rchr(0, PATH_SEPARATOR[0]); + int dirsep = m_fullpath.find_last_of(PATH_SEPARATOR[0]); if (dirsep == -1) return FILERR_NOT_FOUND; @@ -689,19 +690,19 @@ file_error emu_file::attempt_zipped() return FILERR_NOT_FOUND; // insert the part from the right of the separator into the head of the filename - if (filename.len() > 0) - filename.ins(0, "/"); - filename.inssubstr(0, m_fullpath, dirsep + 1, -1); + if (filename.length() > 0) + filename.insert(0, "/"); + filename.insert(0, m_fullpath.substr(dirsep + 1, -1)); // remove this part of the filename and append a .zip extension - m_fullpath.substr(0, dirsep).cat(".zip"); + m_fullpath = m_fullpath.substr(0, dirsep).append(".zip"); // attempt to open the ZIP file zip_file *zip; zip_error ziperr = zip_file_open(m_fullpath.c_str(), &zip); // chop the .zip back off the filename before continuing - m_fullpath.substr(0, dirsep); + m_fullpath = m_fullpath.substr(0, dirsep); // if we failed to open this file, continue scanning if (ziperr != ZIPERR_NONE) @@ -785,10 +786,10 @@ file_error emu_file::load_zipped_file() // to expected filename, ignoring any directory //------------------------------------------------- -bool emu_file::zip_filename_match(const zip_file_header &header, const astring &filename) +bool emu_file::zip_filename_match(const zip_file_header &header, const std::string &filename) { - const char *zipfile = header.filename + header.filename_length - filename.len(); - return (zipfile >= header.filename && filename.icmp(zipfile) == 0 && (zipfile == header.filename || zipfile[-1] == '/')); + const char *zipfile = header.filename + header.filename_length - filename.length(); + return (zipfile >= header.filename && core_stricmp(filename.c_str(),zipfile) == 0 && (zipfile == header.filename || zipfile[-1] == '/')); } @@ -809,13 +810,13 @@ bool emu_file::zip_header_is_path(const zip_file_header &header) file_error emu_file::attempt__7zped() { - astring filename; + std::string filename; // loop over directory parts up to the start of filename while (1) { // find the final path separator - int dirsep = m_fullpath.rchr(0, PATH_SEPARATOR[0]); + int dirsep = m_fullpath.find_last_of(PATH_SEPARATOR[0]); if (dirsep == -1) return FILERR_NOT_FOUND; @@ -824,19 +825,19 @@ file_error emu_file::attempt__7zped() return FILERR_NOT_FOUND; // insert the part from the right of the separator into the head of the filename - if (filename.len() > 0) - filename.ins(0, "/"); - filename.inssubstr(0, m_fullpath, dirsep + 1, -1); + if (filename.length() > 0) + filename.insert(0, "/"); + filename.insert(0, m_fullpath.substr(dirsep + 1, -1)); // remove this part of the filename and append a .7z extension - m_fullpath.substr(0, dirsep).cat(".7z"); + m_fullpath = m_fullpath.substr(0, dirsep).append(".7z"); // attempt to open the _7Z file _7z_file *_7z; _7z_error _7zerr = _7z_file_open(m_fullpath.c_str(), &_7z); // chop the ._7z back off the filename before continuing - m_fullpath.substr(0, dirsep); + m_fullpath = m_fullpath.substr(0, dirsep); // if we failed to open this file, continue scanning if (_7zerr != _7ZERR_NONE) @@ -845,16 +846,16 @@ file_error emu_file::attempt__7zped() int fileno = -1; // see if we can find a file with the right name and (if available) crc - if (m_openflags & OPEN_FLAG_HAS_CRC) fileno = _7z_search_crc_match(_7z, m_crc, filename.c_str(), filename.len(), true, true); + if (m_openflags & OPEN_FLAG_HAS_CRC) fileno = _7z_search_crc_match(_7z, m_crc, filename.c_str(), filename.length(), true, true); // if that failed, look for a file with the right crc, but the wrong filename if (fileno==-1) - if (m_openflags & OPEN_FLAG_HAS_CRC) fileno = _7z_search_crc_match(_7z, m_crc, filename.c_str(), filename.len(), true, false); + if (m_openflags & OPEN_FLAG_HAS_CRC) fileno = _7z_search_crc_match(_7z, m_crc, filename.c_str(), filename.length(), true, false); // if that failed, look for a file with the right name; reporting a bad checksum // is more helpful and less confusing than reporting "rom not found" if (fileno==-1) - fileno = _7z_search_crc_match(_7z, m_crc, filename.c_str(), filename.len(), false, true); + fileno = _7z_search_crc_match(_7z, m_crc, filename.c_str(), filename.length(), false, true); if (fileno != -1) { |