Skip to content

Commit

Permalink
Vutils
Browse files Browse the repository at this point in the history
  • Loading branch information
vic4key committed Aug 27, 2024
1 parent 4a22179 commit 5e8df80
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/Vutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ std::string vuapi extract_file_directory_A(const std::string& file_path, bool la
std::wstring vuapi extract_file_directory_W(const std::wstring& file_path, bool last_slash = true);
std::string vuapi extract_file_name_A(const std::string& file_path, bool extension = true);
std::wstring vuapi extract_file_name_W(const std::wstring& file_path, bool extension = true);
std::string vuapi extract_file_extension_A(const std::string& file_path);
std::wstring vuapi extract_file_extension_W(const std::wstring& file_path);
std::string vuapi get_current_file_path_A();
std::wstring vuapi get_current_file_path_W();
std::string vuapi get_current_directory_A(bool last_slash = true);
Expand Down Expand Up @@ -820,6 +822,7 @@ void vuapi crypt_sha_buffer(
#define write_file_binary write_file_binary_W
#define extract_file_directory extract_file_directory_W
#define extract_file_name extract_file_name_W
#define extract_file_extension extract_file_extension_W
#define get_current_file_path get_current_file_path_W
#define get_current_directory get_current_directory_W
#define get_contain_directory get_contain_directory_W
Expand Down Expand Up @@ -894,6 +897,7 @@ void vuapi crypt_sha_buffer(
#define write_file_binary write_file_binary_A
#define extract_file_directory extract_file_directory_A
#define extract_file_name extract_file_name_A
#define extract_file_extension extract_file_extension_A
#define get_current_file_path get_current_file_path_A
#define get_current_directory get_current_directory_A
#define get_contain_directory get_contain_directory_A
Expand Down
26 changes: 26 additions & 0 deletions src/details/filedir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,32 @@ std::wstring vuapi extract_file_directory_W(const std::wstring& file_path, bool
return result;
}

std::string vuapi extract_file_extension_A(const std::string& file_path)
{
std::string result;

size_t pos_dot = file_path.find_last_of('.');
if (pos_dot != std::string::npos)
{
result = file_path.substr(pos_dot);
}

return result;
}

std::wstring vuapi extract_file_extension_W(const std::wstring& file_path)
{
std::wstring result;

size_t pos_dot = file_path.find_last_of('.');
if (pos_dot != std::wstring::npos)
{
result = file_path.substr(pos_dot);
}

return result;
}

std::string vuapi extract_file_name_A(const std::string& file_path, bool extension)
{
std::string result;
Expand Down

0 comments on commit 5e8df80

Please sign in to comment.