diff --git a/Source/util.cpp b/Source/util.cpp index f7a934d5..e912a85a 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -530,3 +530,9 @@ string get_dir_name(const string& path) { return path.substr(0, last_separator_pos); } +string get_file_name(const string& path) { + string::size_type last_separator_pos = path.rfind(PLATFORM_PATH_SEPARATOR_C); + if (last_separator_pos == string::npos) + return path; + return path.substr(last_separator_pos + 1, string::npos); +} diff --git a/Source/util.h b/Source/util.h index a5eb382f..0fe8464b 100644 --- a/Source/util.h +++ b/Source/util.h @@ -48,6 +48,7 @@ size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm); std::string get_full_path(const std::string &path); std::string get_dir_name(const std::string& path); +std::string get_file_name(const std::string& path); #ifndef _WIN32 char *CharPrev(const char *s, const char *p);