mirror of
https://github.com/nyanmisaka/mpp.git
synced 2026-01-24 02:40:39 +01:00
feat[utils]: Add split_path_file_inplace
Change-Id: I665c382152ac73865bd31b04ccf5fc0d5e942543 Signed-off-by: Xiaoxu Chen <xiaoxu.chen@rock-chips.com>
This commit is contained in:
parent
2507e012c4
commit
e8e44aa0bf
2 changed files with 30 additions and 0 deletions
|
|
@ -1611,3 +1611,31 @@ MPP_RET str_to_frm_fmt(const char *nptr, long *number)
|
|||
RET:
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET split_path_file_inplace(char *fullpath, char **path, char **filename)
|
||||
{
|
||||
char *separator = NULL;
|
||||
char *backslash = NULL;
|
||||
|
||||
if (fullpath == NULL)
|
||||
return MPP_NOK;
|
||||
|
||||
// find last path separator
|
||||
separator = strrchr(fullpath, '/');
|
||||
backslash = strrchr(fullpath, '\\');
|
||||
|
||||
if (backslash && (!separator || backslash > separator)) {
|
||||
separator = backslash;
|
||||
}
|
||||
|
||||
if (separator) {
|
||||
*separator = '\0';
|
||||
*path = fullpath;
|
||||
*filename = separator + 1;
|
||||
} else {
|
||||
*path = ".";
|
||||
*filename = fullpath;
|
||||
}
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ MPP_RET fps_calc_inc(FpsCalc ctx);
|
|||
|
||||
MPP_RET str_to_frm_fmt(const char *nptr, long *number);
|
||||
|
||||
MPP_RET split_path_file_inplace(char *fullpath, char **path, char **filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue