![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
General file name and file path utility declarations. More...
Go to the source code of this file.
Typedefs | |
| typedef struct path_iter | PathIter_T |
Functions | |
| INLINE_IN_H bool_t | PathIsAbsolute (const char *sPath) |
| Check if the given path is an absolute path. More... | |
| char * | NewExpandTilde (const char *sTildeExpr) |
| Expand tilde expression. More... | |
| char * | NewSearchPathExpanded (const char *sSearchPath) |
| Expands search path. More... | |
| char * | NewSearchPathCanonicalized (const char *sSearchPath) |
| Expands and canonicalizes a search path. More... | |
| PathIter_T * | SearchPathIterNew (const char *sSearchPath) |
| Allocates and initilized a new search path iterator. More... | |
| void | SearchPathIterDelete (PathIter_T *pIter) |
| Deletes search path iterator. More... | |
| char * | SearchPathIterFirst (PathIter_T *pIter, const char *sSearchFile) |
| Get the first concatenated file path. More... | |
| char * | SearchPathIterNext (PathIter_T *pIter) |
| Construct next file path from search path and search file name. More... | |
| char * | NewNormPath (const char *sPath) |
| Normalize path. More... | |
| char * | NewRealPath (const char *sPath) |
| Expands and canonicalizes a real path. More... | |
| char * | NewJoinedPath (const char *sPath1, const char *sPath2) |
| Join two file paths. More... | |
General file name and file path utility declarations.
Boths posix (the world) and Microsoft's file and path syntax are supported.
* search_path ::=
* path
* | path path_sep search_path
*
* path ::=
* root rel_path
* | rel_path
*
* root :: =
* std_dir_sep
* | win_dir_sep
* | win_drive win_dir_sep
*
* rel_path ::=
* fname
* | fname dir_sep rel_path
*
* fname ::=
* '.'
* | '.' '.'
* | '~'
* | '~' OSLEGAL_USERNAME
* | '$' indentifier
* | '$' '{' indentifier '}'
* | OSLEGAL_FILENAME
*
* path_sep ::= std_path_sep | win_path_sep
*
* std_path_sep ::= ':'
* win_path_sep ::= ';'
*
* dir_sep ::= std_dir_sep | win_dir_sep
*
* std_dir_sep ::= '/'
* win_dir_sep ::= '\\'
*
* win_drive ::= a-zA-Z ':'
* —
Definition in file path.h.
| typedef struct path_iter PathIter_T |
| char* NewExpandTilde | ( | const char * | sTildeExpr | ) |
Expand tilde expression.
| sTildeExpr | '~' [user] |
Definition at line 157 of file path.c.
References DIR_SEP_CHAR, new_strdup(), NULL, and PATH_SEP_CHAR.
Referenced by NewSearchPathExpanded(), and PathIsAbsolute().
| char* NewJoinedPath | ( | const char * | sPath1, |
| const char * | sPath2 | ||
| ) |
Join two file paths.
The paths are expanded and canonicalized. The paths do not have to exist. If the second, appended path is an absolute path, then the joined path is the second path.
| sPath1 | Front absolute/relative path. |
| sPath2 | Appended, back end path. |
Definition at line 802 of file path.c.
References DIR_SEP_STR, LOGERROR, NewSearchPathCanonicalized(), NEWSTR, NULL, and PathIsAbsolute().
Referenced by PathIsAbsolute().
| char* NewNormPath | ( | const char * | sPath | ) |
Normalize path.
Normalize path, eliminating double slashes and simplifying dot "." current and ".." parent directory references.
The path does not have to exist.
Definition at line 572 of file path.c.
References DIR_SEP_CHAR, DIR_SEP_STR, new_strdup(), NEWSTR, and PathIsAbsolute().
Referenced by NewSearchPathCanonicalized(), and PathIsAbsolute().
| char* NewRealPath | ( | const char * | sPath | ) |
Expands and canonicalizes a real path.
The expanded path must exist.
| sPath | Path file name. |
Definition at line 778 of file path.c.
References NewSearchPathCanonicalized(), and NULL.
Referenced by PathIsAbsolute().
| char* NewSearchPathCanonicalized | ( | const char * | sSearchPath | ) |
Expands and canonicalizes a search path.
The path does not have to exist.
A canonical search path has:
| sSearchPath | Search path of form: path [path_sep path...] |
Definition at line 331 of file path.c.
References NewNormPath(), NewSearchPathExpanded(), NEWSTR, NULL, and PATH_SEP_STR.
Referenced by NewJoinedPath(), NewRealPath(), NewSearchPathDList(), PathIsAbsolute(), and SearchPathIterFirst().
| char* NewSearchPathExpanded | ( | const char * | sSearchPath | ) |
Expands search path.
Expands any environment variables and tilde expressions in search path while building new search path.
The path does not have to exist.
Variable are specified as:
$<identifier> or ${<identifier>} where <identifier> is a legal shell variable name.
Tilde expressions are specified as:
~ or ~user
| sSearchPath | Search path of form: path [path_sep path...] |
Definition at line 227 of file path.c.
References DIR_SEP_CHAR, isidentifier, LOGDIAG4, LOGERROR, LOGFUNCNAME, MAX_SEARCH_PATH, new_strndup(), NewExpandTilde(), NEWSTR, and NULL.
Referenced by NewSearchPathCanonicalized(), and PathIsAbsolute().
| INLINE_IN_H bool_t PathIsAbsolute | ( | const char * | sPath | ) |
Check if the given path is an absolute path.
| sPath | Path name. |
Definition at line 91 of file path.h.
References C_DECLS_END, DIR_SEP_CHAR, NewExpandTilde(), NewJoinedPath(), NewNormPath(), NewRealPath(), NewSearchPathCanonicalized(), NewSearchPathExpanded(), NULL, SearchPathIterDelete(), SearchPathIterFirst(), SearchPathIterNew(), and SearchPathIterNext().
Referenced by NewJoinedPath(), and NewNormPath().
| void SearchPathIterDelete | ( | PathIter_T * | pIter | ) |
Deletes search path iterator.
| pIter | Search path iterator (invalid after return from this call). |
Definition at line 422 of file path.c.
References path_iter::m_pSearchPaths, path_iter::m_sFileCanonical, path_iter::m_sFilePath, and NULL.
Referenced by PathIsAbsolute(), and SearchPathIterNew().
| char* SearchPathIterFirst | ( | PathIter_T * | pIter, |
| const char * | sSearchFile | ||
| ) |
Get the first concatenated file path.
Initialize search path iterator from given search file and returns first concatenated file path.
| pIter | Path iterator. |
| sSearchFile | Search path. |
Definition at line 452 of file path.c.
References DIR_SEP_STR, LOGDIAG4, LOGERROR, LOGFUNCNAME, path_iter::m_bIsEos, path_iter::m_iterPaths, path_iter::m_nFileLen, path_iter::m_pSearchPaths, path_iter::m_sFileCanonical, path_iter::m_sFilePath, NewSearchPathCanonicalized(), NEWSTR, and NULL.
Referenced by PathIsAbsolute().
| PathIter_T* SearchPathIterNew | ( | const char * | sSearchPath | ) |
Allocates and initilized a new search path iterator.
This iterator can be reused multiple times with different search files by calling SearchPathIterFirst(). SearchPathIterDelete() must be called when finished with the iterator to clean up any allocated memory.
| sSearchPath | Search path of form: path [path_sep path...] |
Definition at line 398 of file path.c.
References LOGERROR, path_iter::m_bIsEos, path_iter::m_nFileLen, path_iter::m_pSearchPaths, path_iter::m_sFileCanonical, path_iter::m_sFilePath, NEW, NewSearchPathDList(), NULL, and SearchPathIterDelete().
Referenced by PathIsAbsolute().
| char* SearchPathIterNext | ( | PathIter_T * | pIter | ) |
Construct next file path from search path and search file name.
| pIter | Path iterator. |
Definition at line 526 of file path.c.
References DIR_SEP_STR, LOGDIAG4, LOGFUNCNAME, path_iter::m_bIsEos, path_iter::m_iterPaths, path_iter::m_nFileLen, path_iter::m_sFileCanonical, path_iter::m_sFilePath, NEWSTR, and NULL.
Referenced by PathIsAbsolute().