added a relative function

This commit is contained in:
Leonard Iklé committed 2018-08-31 20:55:45 +02:00
1 parent 7edddaf638
commit 2265646f93
2 files changed
+20 -3

No files matched your search

+12 -1
View File
@@ -118,13 +118,24 @@ void cwk_path_get_root(const char *path, size_t *length);
* @brief Determine whether the path is absolute or not.
*
* This function checks whether the path is an absolute path or not. A path is
* considered to be absolute if it has a root.
* considered to be absolute if the root ends with a separator.
*
* @param path The path which will be checked.
* @return Returns true if the path is absolute or false otherwise.
*/
bool cwk_path_is_absolute(const char *path);
/**
* @brief Determine whether the path is relative or not.
*
* This function checks whether the path is a relative path or not. A path is
* considered to be relative if the root does not end with a separator.
*
* @param path The path which will be checked.
* @return Returns true if the path is relative or false otherwise.
*/
bool cwk_path_is_relative(const char *path);
/**
* @brief Gets the basename from a file path.
*
+8 -2
View File
@@ -382,6 +382,12 @@ bool cwk_path_is_absolute(const char *path)
return cwk_path_is_separator(&path[length - 1]);
}
bool cwk_path_is_relative(const char *path)
{
// The path is relative if it is not absolute.
return !cwk_path_is_absolute(path);
}
void cwk_path_get_basename(const char *path, const char **basename,
size_t *length)
{
@@ -642,7 +648,6 @@ bool cwk_path_get_next_segment(struct cwk_segment *segment)
// Tell the caller that we found a segment.
return true;
}
bool cwk_path_get_previous_segment(struct cwk_segment *segment)
{
const char *c;
@@ -673,6 +678,7 @@ bool cwk_path_get_previous_segment(struct cwk_segment *segment)
return true;
}
enum cwk_segment_type cwk_path_get_segment_type(
const struct cwk_segment *segment)
{
@@ -716,4 +722,4 @@ enum cwk_path_style cwk_path_get_style(void)
{
// Simply return the path style which we store in a global variable.
return path_style;
}
}