diff --git a/include/ctrl_utils/filesystem.h b/include/ctrl_utils/filesystem.h index d5ff05c..c69b290 100644 --- a/include/ctrl_utils/filesystem.h +++ b/include/ctrl_utils/filesystem.h @@ -56,10 +56,15 @@ class path { if (idx_start == idx_end) { return str_.substr(idx_start); } else { - return str_.substr(idx_start, idx_end); + return str_.substr(idx_start, idx_end - idx_start); } } + path filename() const { + const size_t idx_start = str_.find_last_of("/\\") + 1; + return str_.substr(idx_start); + } + bool operator==(const path& other) const { return str_ == other.str_; } private: