|
ECP-VELOC Components
User documentation for all components
|
This file defines the data structure for a path, which is an double-linked list of elements, where each element contains a component (char string). More...
functions to send/recv an spath object
Stores path as a linked list, breaking path at each directory marker and terminating NUL. Can append and insert paths or cut and slice them. Can initialize a path from a string and extract a path into a string. Path consists of a number of components indexed from 0.
Examples:
Definition in file spath.h.
Go to the source code of this file.
Data Structures | |
| struct | spath_elem_struct |
| struct | spath_struct |
Functions | |
Allocate and delete path objects | |
| spath * | spath_new (void) |
| spath * | spath_from_str (const char *str) |
| spath * | spath_from_strf (const char *format,...) |
| spath * | spath_dup (const spath *path) |
| int | spath_delete (spath **ptr_path) |
get size and string functions | |
| int | spath_is_null (const spath *path) |
| int | spath_components (const spath *path) |
| size_t | spath_strlen (const spath *path) |
| size_t | spath_strcpy (char *buf, size_t n, const spath *path) |
| char * | spath_strdup (const spath *path) |
insert, append, prepend functions | |
| int | spath_insert (spath *path1, int offset, const spath *ptr_path2) |
| int | spath_prepend (spath *path1, const spath *ptr_path2) |
| int | spath_append (spath *path1, const spath *ptr_path2) |
| int | spath_insert_str (spath *path, int offset, const char *str) |
| int | spath_prepend_str (spath *path, const char *str) |
| int | spath_append_str (spath *path, const char *str) |
| int | spath_insert_strf (spath *path, int offset, const char *format,...) |
| int | spath_prepend_strf (spath *path, const char *format,...) |
| int | spath_append_strf (spath *path, const char *format,...) |
cut, slice, and subpath functions | |
| int | spath_slice (spath *path, int offset, int length) |
| int | spath_dirname (spath *path) |
| int | spath_basename (spath *path) |
| spath * | spath_sub (spath *path, int offset, int length) |
| spath * | spath_cut (spath *path, int offset) |
simplify and resolve functions | |
| spath * | spath_cwd (void) |
| int | spath_realpath (spath *path) |
| int | spath_reduce (spath *path) |
| char * | spath_strdup_reduce_str (const char *str) |
| int | spath_is_absolute (const spath *path) |
| int | spath_is_child (const spath *parent, const spath *child) |
| spath * | spath_relative (const spath *src, const spath *dst) |
| int spath_append | ( | spath * | path1, |
| const spath * | ptr_path2 | ||
| ) |
appends path2 to path1
| int spath_append_str | ( | spath * | path, |
| const char * | str | ||
| ) |
appends components in string to path
| int spath_append_strf | ( | spath * | path, |
| const char * | format, | ||
| ... | |||
| ) |
adds new components to end of path using printf-like formatting
| int spath_basename | ( | spath * | path | ) |
only leaves last component of path
| int spath_components | ( | const spath * | path | ) |
return number of components in path
| spath* spath_cut | ( | spath * | path, |
| int | offset | ||
| ) |
chops path at specified location and returns remainder as new path, offset can be negative to count from back of path
| spath* spath_cwd | ( | void | ) |
allocate a new path initialized with current working dir
| int spath_delete | ( | spath ** | ptr_path | ) |
frees a path and sets path pointer to NULL
| int spath_dirname | ( | spath * | path | ) |
drops last component from path
| spath* spath_dup | ( | const spath * | path | ) |
allocates and returns a copy of path
| spath* spath_from_str | ( | const char * | str | ) |
allocates a path from string
| spath* spath_from_strf | ( | const char * | format, |
| ... | |||
| ) |
allocates a path from formatted string
| int spath_insert | ( | spath * | path1, |
| int | offset, | ||
| const spath * | ptr_path2 | ||
| ) |
inserts path2 so head element in path2 starts at specified offset in path1, e.g.,
| int spath_insert_str | ( | spath * | path, |
| int | offset, | ||
| const char * | str | ||
| ) |
inserts components in string so first component in string starts at specified offset in path, e.g.,
| int spath_insert_strf | ( | spath * | path, |
| int | offset, | ||
| const char * | format, | ||
| ... | |||
| ) |
inserts components in string so first component in string starts at specified offset in path, e.g.,
| int spath_is_absolute | ( | const spath * | path | ) |
return 1 if path starts with an empty string, 0 otherwise
| int spath_is_child | ( | const spath * | parent, |
| const spath * | child | ||
| ) |
return 1 if child is contained in tree starting at parent, 0 otherwise
| int spath_is_null | ( | const spath * | path | ) |
returns 1 if path has 0 components, 0 otherwise
| spath* spath_new | ( | void | ) |
allocates a new path
| int spath_prepend | ( | spath * | path1, |
| const spath * | ptr_path2 | ||
| ) |
prepends path2 to path1
| int spath_prepend_str | ( | spath * | path, |
| const char * | str | ||
| ) |
prepends components in string to path
| int spath_prepend_strf | ( | spath * | path, |
| const char * | format, | ||
| ... | |||
| ) |
prepends components in string to path
| int spath_realpath | ( | spath * | path | ) |
apply realpath to given path
| int spath_reduce | ( | spath * | path | ) |
removes consecutive '/', '.', '..', and trailing '/'
| spath* spath_relative | ( | const spath * | src, |
| const spath * | dst | ||
| ) |
compute and return relative path from src to dst
| int spath_slice | ( | spath * | path, |
| int | offset, | ||
| int | length | ||
| ) |
keeps upto length components of path starting at specified location and discards the rest, offset can be negative to count from back, a negative length copies the remainder of the string
| size_t spath_strcpy | ( | char * | buf, |
| size_t | n, | ||
| const spath * | path | ||
| ) |
copy string into user buffer, abort if buffer is too small, return number of bytes written
| char* spath_strdup | ( | const spath * | path | ) |
allocate memory and return path in string form, caller is responsible for freeing string with free()
| char* spath_strdup_reduce_str | ( | const char * | str | ) |
creates path from string, calls reduce, calls path_strdup, and deletes path, caller must free returned string with free
| size_t spath_strlen | ( | const spath * | path | ) |
return number of characters needed to store path (excludes terminating NUL)
| spath* spath_sub | ( | spath * | path, |
| int | offset, | ||
| int | length | ||
| ) |
copies upto length components of path starting at specified location and returns subpath as new path, offset can be negative to count from back, a negative length copies the remainder of the string
1.8.17