All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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,...)
 

Detailed Description

Legato Path API include file.

Copyright (C) Sierra Wireless, Inc. 2013. All rights reserved. Use of this work is subject to license.

Function Documentation

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]separatorPtrSeparator string.
[in,out]pathPtrBuffer containing the first segment and where the resultant path will be stored.
[in]pathSizeBuffer size.
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]pathPtrPath string.
[in]separatorPtrSeparator string.
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]pathPtrPath string.
[in]separatorPtrSeparator string.
[out]dirPtrBuffer to store the directory string.
[in]dirBuffSizeSize of the directory buffer in bytes.