* @brief Extract the last component from a path string * * This function extracts the filename or last directory name from a given path. * It searches for the last '/' character and returns the substring after it. * * @param[in] path The input path string to process * * @return const char* Pointer to: * - The last path component if '/' is found * - The original path if no
| 2914 | * - NULL if input path is NULL |
| 2915 | */ |
| 2916 | static const char *_get_path_lastname(const char *path) |
| 2917 | { |
| 2918 | char *ptr; |
| 2919 | if ((ptr = (char *)strrchr(path, '/')) == NULL) |
| 2920 | return path; |
| 2921 | |
| 2922 | /* skip the '/' then return */ |
| 2923 | return ++ptr; |
| 2924 | } |
| 2925 | |
| 2926 | /** |
| 2927 | * @brief Copy files or directories from source to destination |