le_path.h File Reference
Go to the source code of this file.
Functions | |
le_result_t | le_path_GetDir (const char *pathPtr, const char *separatorPtr, char *dirPtr, size_t dirBuffSize) |
char * | le_path_GetBasenamePtr (const char *pathPtr, const char *separatorPtr) |
le_result_t | le_path_Concat (const char *separatorPtr, char *pathPtr, size_t pathSize,...) |
bool | le_path_IsSubpath (const char *path1Ptr, const char *path2Ptr, const char *separatorPtr) |
bool | le_path_IsEquivalent (const char *path1Ptr, const char *path2Ptr, const char *separatorPtr) |
char * | le_path_FindTrailing (const char *pathPtr, const char *extPtr) |
Detailed Description
Legato Path API include file.
Copyright (C) Sierra Wireless Inc. license.
Function Documentation
◆ le_path_Concat()
le_result_t le_path_Concat | ( | const char * | separatorPtr, |
char * | pathPtr, | ||
size_t | pathSize, | ||
... | |||
) |
Concatenates multiple path segments together.
Concatenates the path in the pathPtr buffer with all path segments and stores the result in the pathPtr. Ensures that where path segments are joined there is only one separator between them. Duplicate trailing separators in the resultant path are also dropped.
If there is not enough space in pathPtr for all segments, as many characters from the segments that will fit in the buffer will be copied and LE_OVERFLOW will be returned. Partial UTF-8 characters and partial separators will never be copied.
- Warning
- The (char*)NULL at the end of the list of path segments is mandatory. If this NULL is omitted the behaviour is undefined.
- Returns
- LE_OK if successful. LE_OVERFLOW if there was not enough buffer space in pathPtr for all segments.
- Parameters
-
[in] separatorPtr Separator string. [in,out] pathPtr Buffer containing the first segment and where the resultant path will be stored. [in] pathSize Buffer size.
◆ le_path_FindTrailing()
char* le_path_FindTrailing | ( | const char * | pathPtr, |
const char * | extPtr | ||
) |
Checks if a path has a particular trailing substring. For example, path
pathPtr = /path/to/file.txt
contains a trailing substring
extPtr = .txt
- Returns
- pointer to existing trailing susbstring within path, or NULL otherwise.
- Parameters
-
[in] pathPtr Path string. [in] extPtr Trailing substring.
◆ le_path_GetBasenamePtr()
char* le_path_GetBasenamePtr | ( | const char * | pathPtr, |
const char * | separatorPtr | ||
) |
Gets a pointer to the basename (the last node in the path). This function gets the basename by returning a pointer to the character following the last separator.
- Returns
- Pointer to the character following the last separator.
- Parameters
-
[in] pathPtr Path string. [in] separatorPtr Separator string.
◆ le_path_GetDir()
le_result_t le_path_GetDir | ( | const char * | pathPtr, |
const char * | separatorPtr, | ||
char * | dirPtr, | ||
size_t | dirBuffSize | ||
) |
Gets the directory, which is the entire path up to and including the last separator.
- Returns
- LE_OK if succesful. LE_OVERFLOW if the dirPtr buffer is too small.
- Parameters
-
[in] pathPtr Path string. [in] separatorPtr Separator string. [out] dirPtr Buffer to store the directory string. [in] dirBuffSize Size of the directory buffer in bytes.
◆ le_path_IsEquivalent()
bool le_path_IsEquivalent | ( | const char * | path1Ptr, |
const char * | path2Ptr, | ||
const char * | separatorPtr | ||
) |
Checks if path1 and path2 are equivalent, ignoring trailing separators. For example, all the following paths are equivalent.
/a/b/c /a/b/c/ /a/b/c///
- Returns
- true if path1 is equivalent to path2. false otherwise.
- Parameters
-
[in] path1Ptr Path 1 string. [in] path2Ptr Path 2 string. [in] separatorPtr Separator string.
◆ le_path_IsSubpath()
bool le_path_IsSubpath | ( | const char * | path1Ptr, |
const char * | path2Ptr, | ||
const char * | separatorPtr | ||
) |
Checks if path2 is a subpath of path1. That is path2 has the same starting nodes as path2. For example, path2 is a subpath of path1 if:
path1 = /a/b/c path2 = /a/b/c/d/e
- Returns
- true if path2 is a subpath of path1. false otherwise.
- Parameters
-
[in] path1Ptr Path 1 string. [in] path2Ptr Path 2 string. [in] separatorPtr Separator string.