diff options
author | 2016-07-10 23:38:44 -0400 | |
---|---|---|
committer | 2016-07-10 23:38:44 -0400 | |
commit | 09b3fbf52cbaf756b0e3e55773161aa53290b1d0 (patch) | |
tree | 0f07ce57dfd44e10442fdb284369233ff9bf96d2 | |
parent | e48008b5165510f267a93f6a1b85e34a5878a1ac (diff) |
C++-ification of some corefile static functions
-rw-r--r-- | src/lib/util/corefile.cpp | 16 | ||||
-rw-r--r-- | src/lib/util/corefile.h | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp index 09d99c2072b..01c539680a2 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -1270,11 +1270,11 @@ core_file::core_file() 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 */ - const char *start = name + strlen(name); - while (start > name && !util::is_directory_separator(start[-1])) + const char *start = name.c_str() + name.length(); + while (start > name.c_str() && !util::is_directory_separator(start[-1])) start--; /* 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? -------------------------------------------------*/ -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); - int extlen = strlen(extension); - int matches = TRUE; + auto namelen = filename.length(); + auto extlen = extension.length(); + bool matches = true; /* work backwards checking for a match */ while (extlen > 0) if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen])) { - matches = FALSE; + matches = false; break; } diff --git a/src/lib/util/corefile.h b/src/lib/util/corefile.h index 8f71832411f..5fa6d5af9a7 100644 --- a/src/lib/util/corefile.h +++ b/src/lib/util/corefile.h @@ -140,10 +140,10 @@ protected: /* ----- filename utilities ----- */ /* 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 */ -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 |