path.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <m-string.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /**
  7. * @brief Extract filename without extension from path.
  8. *
  9. * @param path path string
  10. * @param filename output filename string. Must be initialized before.
  11. */
  12. void path_extract_filename_no_ext(const char* path, string_t filename);
  13. /**
  14. * @brief Extract last path component
  15. *
  16. * @param path path string
  17. * @param filename output string. Must be initialized before.
  18. */
  19. void path_extract_basename(const char* path, string_t basename);
  20. /**
  21. * @brief Extract path, except for last component
  22. *
  23. * @param path path string
  24. * @param filename output string. Must be initialized before.
  25. */
  26. void path_extract_dirname(const char* path, string_t dirname);
  27. /**
  28. * @brief Appends new component to path, adding path delimiter
  29. *
  30. * @param path path string
  31. * @param suffix path part to apply
  32. */
  33. void path_append(string_t path, const char* suffix);
  34. /**
  35. * @brief Appends new component to path, adding path delimiter
  36. *
  37. * @param path first path part
  38. * @param suffix second path part
  39. * @param out_path output string to combine parts into. Must be initialized
  40. */
  41. void path_concat(const char* path, const char* suffix, string_t out_path);
  42. #ifdef __cplusplus
  43. }
  44. #endif