Skip to content

Commit

Permalink
Merge branch 'master' into memory-hog
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Aug 2, 2022
2 parents 2233769 + c75b76d commit 5b8f6d1
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 43 deletions.
10 changes: 10 additions & 0 deletions Utilities/StrFmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,13 @@ bool fmt::match(const std::string& source, const std::string& mask)

return true;
}

std::string get_file_extension(const std::string& file_path)
{
if (usz dotpos = file_path.find_last_of('.'); dotpos != std::string::npos && dotpos + 1 < file_path.size())
{
return file_path.substr(dotpos + 1);
}

return {};
}
3 changes: 3 additions & 0 deletions Utilities/StrUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ bool try_to_int64(s64* out, std::string_view value, s64 min, s64 max);
// Convert string to unsigned integer
bool try_to_uint64(u64* out, std::string_view value, u64 min, u64 max);

// Get the file extension of a file path ("png", "jpg", etc.)
std::string get_file_extension(const std::string& file_path);

namespace fmt
{
std::string replace_all(std::string_view src, std::string_view from, std::string_view to, usz count = -1);
Expand Down
Loading

0 comments on commit 5b8f6d1

Please sign in to comment.