Filesystem path utilities.
More...
#include <core/string.h>
Go to the source code of this file.
|
| void | path_extract_filename_no_ext (const char *path, FuriString *filename) |
| | Extract filename without extension from path.
|
| |
| void | path_extract_filename (FuriString *path, FuriString *filename, bool trim_ext) |
| | Extract filename string from path.
|
| |
| void | path_extract_extension (FuriString *path, char *ext, size_t ext_len_max) |
| | Extract file extension from path.
|
| |
| void | path_extract_basename (const char *path, FuriString *basename) |
| | Extract last path component.
|
| |
| void | path_extract_dirname (const char *path, FuriString *dirname) |
| | Extract path, except for last component.
|
| |
| void | path_append (FuriString *path, const char *suffix) |
| | Appends new component to path, adding path delimiter.
|
| |
| void | path_concat (const char *path, const char *suffix, FuriString *out_path) |
| | Appends new component to path, adding path delimiter.
|
| |
| bool | path_contains_only_ascii (const char *path) |
| | Check that path contains only ascii characters.
|
| |
| void | path_normalize (const char *path, FuriString *out_path, bool allow_escape_root) |
| | Normalizes path (resolves current and parent directory references).
|
| |
| bool | path_replace_prefix (const char *path, const char *old_prefix, const char *new_prefix, FuriString *out_path) |
| | Replaces an old path prefix with a new one.
|
| |
Filesystem path utilities.
◆ path_append()
| void path_append |
( |
FuriString * | path, |
|
|
const char * | suffix ) |
Appends new component to path, adding path delimiter.
- Parameters
-
| path | path string |
| suffix | path part to apply |
◆ path_concat()
| void path_concat |
( |
const char * | path, |
|
|
const char * | suffix, |
|
|
FuriString * | out_path ) |
Appends new component to path, adding path delimiter.
- Parameters
-
| path | first path part |
| suffix | second path part |
| out_path | output string to combine parts into. Must be initialized |
◆ path_contains_only_ascii()
| bool path_contains_only_ascii |
( |
const char * | path | ) |
|
Check that path contains only ascii characters.
- Parameters
-
- Returns
true if the paths contains only ASCII characters, false otherwise
◆ path_extract_basename()
| void path_extract_basename |
( |
const char * | path, |
|
|
FuriString * | basename ) |
Extract last path component.
- Parameters
-
| path | path string |
| basename | output string. Must be initialized before. |
◆ path_extract_dirname()
| void path_extract_dirname |
( |
const char * | path, |
|
|
FuriString * | dirname ) |
Extract path, except for last component.
- Parameters
-
| path | path string |
| dirname | output string. Must be initialized before. |
◆ path_extract_extension()
| void path_extract_extension |
( |
FuriString * | path, |
|
|
char * | ext, |
|
|
size_t | ext_len_max ) |
Extract file extension from path.
- Parameters
-
| path | path string |
| ext | output extension string |
| ext_len_max | maximum extension string length |
◆ path_extract_filename()
| void path_extract_filename |
( |
FuriString * | path, |
|
|
FuriString * | filename, |
|
|
bool | trim_ext ) |
Extract filename string from path.
- Parameters
-
| path | path string |
| filename | output filename string. Must be initialized before. |
| trim_ext | true - get filename without extension |
◆ path_extract_filename_no_ext()
| void path_extract_filename_no_ext |
( |
const char * | path, |
|
|
FuriString * | filename ) |
Extract filename without extension from path.
- Parameters
-
| path | path string |
| filename | output filename string. Must be initialized before. |
◆ path_normalize()
| void path_normalize |
( |
const char * | path, |
|
|
FuriString * | out_path, |
|
|
bool | allow_escape_root ) |
Normalizes path (resolves current and parent directory references).
- Parameters
-
| path | path to normalize |
| out_path | output string to normalize path into. Must be initialized |
| allow_escape_root | if true, resulting paths can reference parents of current directory. |
path_normalize("a/../../b", out_path, true);
path_normalize("a/../../b", out_path, false);
◆ path_replace_prefix()
| bool path_replace_prefix |
( |
const char * | path, |
|
|
const char * | old_prefix, |
|
|
const char * | new_prefix, |
|
|
FuriString * | out_path ) |
Replaces an old path prefix with a new one.
- Parameters
-
| [in] | path | input path |
| [in] | old_prefix | prefix to be replaced |
| [in] | new_prefix | new prefix to be used |
| [in,out] | out_path | pointer to the path output string (must be allocated) |
- Returns
- true on success, false if path does not start with old_prefix
path_replace_prefix("/a/b/c/foo", "/a/b", "/g", out_path);
path_replace_prefix("/a/bar/c/foo", "/a/b", "/g", out_path);