Skip to content

Commit 9266de0

Browse files
committed
Add parsing of file extension from file path-name.
1 parent 632ae4b commit 9266de0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/util/file_util.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ std::string fileutl_parse_name_in_pathname(std::string const &file_pathname)
201201
return file_pathname.substr(fileutl_parse_last_dir_pos(file_pathname));
202202
}
203203

204+
std::string fileutl_parse_extension_in_pathname(std::string const &pathname)
205+
{
206+
const std::size_t idx=pathname.find_last_of('.');
207+
return idx==std::string::npos ? std::string("") : pathname.substr(idx);
208+
}
209+
204210
std::string fileutl_parse_path_in_pathname(std::string const &file_pathname)
205211
{
206212
return file_pathname.substr(0U, fileutl_parse_last_dir_pos(file_pathname));

src/util/file_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ uint64_t fileutl_file_size(std::string const &file_pathname);
3535

3636
std::string fileutl_parse_name_in_pathname(std::string const &file_pathname);
3737

38+
std::string fileutl_parse_extension_in_pathname(std::string const &pathname);
39+
3840
std::string fileutl_parse_path_in_pathname(std::string const &file_pathname);
3941

4042
std::string fileutl_remove_extension(std::string const &filename);

0 commit comments

Comments
 (0)