YAP 7.1.0
cwalk.h
1#pragma once
2
3#ifndef CWK_LIBRARY_H
4#define CWK_LIBRARY_H
5
6#include <stdbool.h>
7#include <stddef.h>
8
15{
16 const char *path;
17 const char *segments;
18 const char *begin;
19 const char *end;
20 size_t size;
21};
22
31enum cwk_segment_type
32{
33 CWK_NORMAL,
34 CWK_CURRENT,
35 CWK_BACK
36};
37
42enum cwk_path_style
43{
44 CWK_STYLE_WINDOWS,
45 CWK_STYLE_UNIX
46};
47
66size_t cwk_path_get_absolute(const char *base, const char *path, char *buffer,
67 size_t buffer_size);
68
86size_t cwk_path_get_relative(const char *base_directory, const char *path,
87 char *buffer, size_t buffer_size);
88
106size_t cwk_path_join(const char *path_a, const char *path_b, char *buffer,
107 size_t buffer_size);
108
126size_t cwk_path_join_multiple(const char **paths, char *buffer,
127 size_t buffer_size);
128
139void cwk_path_get_root(const char *path, size_t *length);
140
158size_t cwk_path_change_root(const char *path, const char *new_root,
159 char *buffer, size_t buffer_size);
160
170bool cwk_path_is_absolute(const char *path);
171
181bool cwk_path_is_relative(const char *path);
182
196void cwk_path_get_basename(const char *path, const char **basename,
197 size_t *length);
198
217size_t cwk_path_change_basename(const char *path, const char *new_basename,
218 char *buffer, size_t buffer_size);
219
231void cwk_path_get_dirname(const char *path, size_t *length);
232
248bool cwk_path_get_extension(const char *path, const char **extension,
249 size_t *length);
250
260bool cwk_path_has_extension(const char *path);
261
282size_t cwk_path_change_extension(const char *path, const char *new_extension,
283 char *buffer, size_t buffer_size);
284
307size_t cwk_path_normalize(const char *path, char *buffer, size_t buffer_size);
308
320size_t cwk_path_get_intersection(const char *path_base, const char *path_other);
321
333bool cwk_path_get_first_segment(const char *path, struct cwk_segment *segment);
334
348bool cwk_path_get_last_segment(const char *path, struct cwk_segment *segment);
349
360bool cwk_path_get_next_segment(struct cwk_segment *segment);
361
373bool cwk_path_get_previous_segment(struct cwk_segment *segment);
374
386enum cwk_segment_type cwk_path_get_segment_type(
387 const struct cwk_segment *segment);
388
406size_t cwk_path_change_segment(struct cwk_segment *segment, const char *value,
407 char *buffer, size_t buffer_size);
408
420bool cwk_path_is_separator(const char *str);
421
432enum cwk_path_style cwk_path_guess_style(const char *path);
433
445void cwk_path_set_style(enum cwk_path_style style);
446
455enum cwk_path_style cwk_path_get_style(void);
456
457#endif
A segment represents a single component of a path.
Definition: cwalk.h:15