String manupulation for file and path names
[File/Path Manupulation API]
String manupulation routines manage strings so that they are grammartical for path and file names.
More...Functions | |
FILEPATHAPI ucs2char_t * | filepath_addslash (ucs2char_t *path) |
Add a (back)slash character to the end of a string. | |
FILEPATHAPI ucs2char_t * | filepath_removeslash (ucs2char_t *path) |
Remove a (back)slash character from the end of a string. | |
FILEPATHAPI const ucs2char_t * | filepath_combinepath (ucs2char_t *dst, size_t size, const ucs2char_t *path, const ucs2char_t *file) |
Concatenate two strings into one well-formed path. | |
FILEPATHAPI void | filepath_strippath (ucs2char_t *path) |
Remove the path portion of a filepath name. | |
FILEPATHAPI const ucs2char_t * | filepath_skippath (const ucs2char_t *path) |
Skip the path portion in a filepath name. | |
FILEPATHAPI void | filepath_remove_filespec (ucs2char_t *path) |
Remove the file portion from a string. | |
FILEPATHAPI const ucs2char_t * | filepath_skiproot (const ucs2char_t *path, const ucs2char_t *root) |
Skip a portion in a filepath name. | |
FILEPATHAPI const ucs2char_t * | filepath_changeroot (const ucs2char_t *path, const ucs2char_t *root) |
Skip a portion in filepath name, assuming it as the root directory. | |
FILEPATHAPI const ucs2char_t * | filepath_skipadirectory (const ucs2char_t *path) |
Skip a directory name in filepath name. | |
FILEPATHAPI void | filepath_add_extension (ucs2char_t *path, const ucs2char_t *ext) |
Add a file extension to the end of a string. | |
FILEPATHAPI void | filepath_remove_extension (ucs2char_t *path) |
Remove a file extension from the end of a string. | |
FILEPATHAPI int | filepath_relative_to_absolute (ucs2char_t *absolute, const ucs2char_t *base, const ucs2char_t *relative) |
Convert a relative path to its corresponding absolute path. | |
FILEPATHAPI int | filepath_path_canonicalize (ucs2char_t *dst, const ucs2char_t *src) |
Canonicalize a path. | |
FILEPATHAPI int | filepath_encode (ucs2char_t *path) |
Replaces all path separators with a backslash ('\') separator. | |
FILEPATHAPI int | filepath_decode (ucs2char_t *path) |
Replaces '\'-slashes in a path name with the native path separator. |
Detailed Description
String manupulation routines manage strings so that they are grammartical for path and file names.
Function Documentation
FILEPATHAPI void filepath_add_extension | ( | ucs2char_t * | path, | |
const ucs2char_t * | ext | |||
) |
Add a file extension to the end of a string.
- Parameters:
-
path The pointer to the string. ext The pointer to the file extension.
FILEPATHAPI ucs2char_t* filepath_addslash | ( | ucs2char_t * | path | ) |
Add a (back)slash character to the end of a string.
This function adds a (back)slash character to the end of the string if the resultant string is grammertical. If the string already has a trailing (back)slash, this function will not change it.
- Parameters:
-
path The pointer to the string.
- Return values:
-
ucs2char_t* Identical value to path argument.
FILEPATHAPI const ucs2char_t* filepath_changeroot | ( | const ucs2char_t * | path, | |
const ucs2char_t * | root | |||
) |
Skip a portion in filepath name, assuming it as the root directory.
The resultant string will begin with a path character.
- Parameters:
-
path The pointer to the filepath name from which this function skips the portion. root The pointer to the string representing the portion to be skipped.
- Return values:
-
const ucs2char_t* The pointer at the next character after the portion root ends in path.
FILEPATHAPI const ucs2char_t* filepath_combinepath | ( | ucs2char_t * | dst, | |
size_t | size, | |||
const ucs2char_t * | path, | |||
const ucs2char_t * | file | |||
) |
Concatenate two strings into one well-formed path.
- Parameters:
-
dst The pointer to a buffer to receive the resultant path. size The size, in number of UCS-2 characters, of dst. path The pointer to a path name. file The pointer to a file name.
- Return values:
-
const ucs2char_t* The identical value to dst argument.
FILEPATHAPI int filepath_decode | ( | ucs2char_t * | path | ) |
Replaces '\'-slashes in a path name with the native path separator.
This function replaces all Windows-style path separators (back-slashes) in the given path with the native path separator. On POSIX systems, the replacement character is a forward slash ('/'). On Windows, this is a no-op. The path
is modified in place.
- Parameters:
-
path The pointer to the path string to be converted.
- Returns:
- int Reserved.
FILEPATHAPI int filepath_encode | ( | ucs2char_t * | path | ) |
Replaces all path separators with a backslash ('\') separator.
This function replaces all path separators in the given path with Windows-style path separators (back-slashes). On POSIX systems, this means converting forward slash ('/') path separators into backslashes. On Windows, this is a no-op. The path
is modified in place.
- Parameters:
-
path The pointer to the path string to be converted.
- Returns:
- int Reserved.
FILEPATHAPI int filepath_path_canonicalize | ( | ucs2char_t * | dst, | |
const ucs2char_t * | src | |||
) |
Canonicalize a path.
- Parameters:
-
dst The pointer to a buffer to receive the resultant path. src The path to be canonicalized.
- Return values:
-
Non-zero value if successful, zero otherwise.
FILEPATHAPI int filepath_relative_to_absolute | ( | ucs2char_t * | absolute, | |
const ucs2char_t * | base, | |||
const ucs2char_t * | relative | |||
) |
Convert a relative path to its corresponding absolute path.
- Parameters:
-
absolute The pointer to a buffer to receive the resultant path. base The name of the base directory where the relative path begins. relative The relative path to be converted.
- Return values:
-
int Reserved (0).
FILEPATHAPI void filepath_remove_extension | ( | ucs2char_t * | path | ) |
Remove a file extension from the end of a string.
- Parameters:
-
path The pointer to the string from which the extension is removed.
FILEPATHAPI void filepath_remove_filespec | ( | ucs2char_t * | path | ) |
Remove the file portion from a string.
- Parameters:
-
path The pointer to the string from which the file portion is removed.
FILEPATHAPI ucs2char_t* filepath_removeslash | ( | ucs2char_t * | path | ) |
Remove a (back)slash character from the end of a string.
This function removes a (back)slash character from the end of the string if the resultant string is grammertical. If the string already has no trailing (back)slash, this function will not change it.
- Parameters:
-
path The pointer to the string.
- Return values:
-
ucs2char_t* The identical value to path argument.
FILEPATHAPI const ucs2char_t* filepath_skipadirectory | ( | const ucs2char_t * | path | ) |
Skip a directory name in filepath name.
- Parameters:
-
path The pointer to the filepath name from which this function skips a directory name.
- Return values:
-
const ucs2char_t* The pointer at the next character after the directory name ends in path.
FILEPATHAPI const ucs2char_t* filepath_skippath | ( | const ucs2char_t * | path | ) |
Skip the path portion in a filepath name.
- Parameters:
-
path The pointer to the filepath name from which this function skips the path portion. The skipped string will contain only the file portion.
- Return values:
-
const ucs2char_t* The pointer at which the file portion begins.
FILEPATHAPI const ucs2char_t* filepath_skiproot | ( | const ucs2char_t * | path, | |
const ucs2char_t * | root | |||
) |
Skip a portion in a filepath name.
- Parameters:
-
path The pointer to the filepath name from which this function skips the portion. root The pointer to the string representing the portion to be skipped.
- Return values:
-
const ucs2char_t* The pointer at the next character after the portion root ends in path.
FILEPATHAPI void filepath_strippath | ( | ucs2char_t * | path | ) |
Remove the path portion of a filepath name.
- Parameters:
-
path The pointer to the filepath name from which this function removes the path portion. The resultant string will contain only the file portion.