utils/file: add basename/dirname helpers and use them
This commit is contained in:
@ -151,6 +151,18 @@ Mu::canonicalize_filename(const std::string& path, const std::string& relative_t
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string
|
||||
Mu::basename(const std::string& path)
|
||||
{
|
||||
return to_string_gchar(g_path_get_basename(path.c_str()));
|
||||
}
|
||||
|
||||
std::string
|
||||
Mu::dirname(const std::string& path)
|
||||
{
|
||||
return to_string_gchar(g_path_get_dirname(path.c_str()));
|
||||
}
|
||||
|
||||
Result<std::string>
|
||||
Mu::make_temp_dir()
|
||||
{
|
||||
|
||||
@ -85,6 +85,28 @@ std::string canonicalize_filename(const std::string& path, const std::string& re
|
||||
Result<std::string> expand_path(const std::string& str);
|
||||
|
||||
|
||||
/**
|
||||
* Get the basename for path, i.e. without leading directory component,
|
||||
* @see g_path_get_basename
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return the basename
|
||||
*/
|
||||
std::string basename(const std::string& path);
|
||||
|
||||
|
||||
/**
|
||||
* Get the dirname for path, i.e. without leading directory component,
|
||||
* @see g_path_get_dirname
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return the dirname
|
||||
*/
|
||||
std::string dirname(const std::string& path);
|
||||
|
||||
|
||||
/*
|
||||
* for OSs with out support for direntry->d_type, like Solaris
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user