mirror of
https://github.com/holub/mame
synced 2025-06-28 15:14:21 +03:00
C++-ification of some corefile static functions
This commit is contained in:
parent
e48008b516
commit
09b3fbf52c
@ -1270,11 +1270,11 @@ core_file::core_file()
|
|||||||
assumptions about path separators
|
assumptions about path separators
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
std::string core_filename_extract_base(const char *name, bool strip_extension)
|
std::string core_filename_extract_base(const std::string &name, bool strip_extension)
|
||||||
{
|
{
|
||||||
/* find the start of the name */
|
/* find the start of the name */
|
||||||
const char *start = name + strlen(name);
|
const char *start = name.c_str() + name.length();
|
||||||
while (start > name && !util::is_directory_separator(start[-1]))
|
while (start > name.c_str() && !util::is_directory_separator(start[-1]))
|
||||||
start--;
|
start--;
|
||||||
|
|
||||||
/* copy the rest into an astring */
|
/* copy the rest into an astring */
|
||||||
@ -1292,17 +1292,17 @@ std::string core_filename_extract_base(const char *name, bool strip_extension)
|
|||||||
filename end with the specified extension?
|
filename end with the specified extension?
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
int core_filename_ends_with(const char *filename, const char *extension)
|
bool core_filename_ends_with(const std::string &filename, const std::string &extension)
|
||||||
{
|
{
|
||||||
int namelen = strlen(filename);
|
auto namelen = filename.length();
|
||||||
int extlen = strlen(extension);
|
auto extlen = extension.length();
|
||||||
int matches = TRUE;
|
bool matches = true;
|
||||||
|
|
||||||
/* work backwards checking for a match */
|
/* work backwards checking for a match */
|
||||||
while (extlen > 0)
|
while (extlen > 0)
|
||||||
if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen]))
|
if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen]))
|
||||||
{
|
{
|
||||||
matches = FALSE;
|
matches = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,10 +140,10 @@ protected:
|
|||||||
/* ----- filename utilities ----- */
|
/* ----- filename utilities ----- */
|
||||||
|
|
||||||
/* extract the base part of a filename (remove extensions and paths) */
|
/* extract the base part of a filename (remove extensions and paths) */
|
||||||
std::string core_filename_extract_base(const char *name, bool strip_extension = false);
|
std::string core_filename_extract_base(const std::string &name, bool strip_extension = false);
|
||||||
|
|
||||||
/* true if the given filename ends with a particular extension */
|
/* true if the given filename ends with a particular extension */
|
||||||
int core_filename_ends_with(const char *filename, const char *extension);
|
bool core_filename_ends_with(const std::string &filename, const std::string &extension);
|
||||||
|
|
||||||
|
|
||||||
#endif // MAME_LIB_UTIL_COREFILE_H
|
#endif // MAME_LIB_UTIL_COREFILE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user