Stardew Engine
Loading...
Searching...
No Matches
cwalk.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef CWK_LIBRARY_H
4#define CWK_LIBRARY_H
5
6#include <stdbool.h>
7#include <stddef.h>
8
9#if defined(_WIN32) || defined(__CYGWIN__)
10#define CWK_EXPORT __declspec(dllexport)
11#define CWK_IMPORT __declspec(dllimport)
12#elif __GNUC__ >= 4
13#define CWK_EXPORT __attribute__((visibility("default")))
14#define CWK_IMPORT __attribute__((visibility("default")))
15#else
16#define CWK_EXPORT
17#define CWK_IMPORT
18#endif
19
20#if defined(CWK_SHARED)
21#if defined(CWK_EXPORTS)
22#define CWK_PUBLIC CWK_EXPORT
23#else
24#define CWK_PUBLIC CWK_IMPORT
25#endif
26#else
27#define CWK_PUBLIC
28#endif
29
30#ifdef __cplusplus
31extern "C"
32{
33#endif
34
41{
42 const char *path;
43 const char *segments;
44 const char *begin;
45 const char *end;
46 size_t size;
47};
48
63
73
93CWK_PUBLIC size_t cwk_path_get_absolute(const char *base, const char *path,
94 char *buffer, size_t buffer_size);
95
114CWK_PUBLIC size_t cwk_path_get_relative(const char *base_directory,
115 const char *path, char *buffer, size_t buffer_size);
116
135CWK_PUBLIC size_t cwk_path_join(const char *path_a, const char *path_b,
136 char *buffer, size_t buffer_size);
137
156CWK_PUBLIC size_t cwk_path_join_multiple(const char **paths, char *buffer,
157 size_t buffer_size);
158
169CWK_PUBLIC void cwk_path_get_root(const char *path, size_t *length);
170
188CWK_PUBLIC size_t cwk_path_change_root(const char *path, const char *new_root,
189 char *buffer, size_t buffer_size);
190
200CWK_PUBLIC bool cwk_path_is_absolute(const char *path);
201
211CWK_PUBLIC bool cwk_path_is_relative(const char *path);
212
228CWK_PUBLIC void cwk_path_get_basename(const char *path, const char **basename,
229 size_t *length);
230
249CWK_PUBLIC size_t cwk_path_change_basename(const char *path,
250 const char *new_basename, char *buffer, size_t buffer_size);
251
263CWK_PUBLIC void cwk_path_get_dirname(const char *path, size_t *length);
264
280CWK_PUBLIC bool cwk_path_get_extension(const char *path, const char **extension,
281 size_t *length);
282
292CWK_PUBLIC bool cwk_path_has_extension(const char *path);
293
315CWK_PUBLIC size_t cwk_path_change_extension(const char *path,
316 const char *new_extension, char *buffer, size_t buffer_size);
317
341CWK_PUBLIC size_t cwk_path_normalize(const char *path, char *buffer,
342 size_t buffer_size);
343
355CWK_PUBLIC size_t cwk_path_get_intersection(const char *path_base,
356 const char *path_other);
357
369CWK_PUBLIC bool cwk_path_get_first_segment(const char *path,
370 struct cwk_segment *segment);
371
385CWK_PUBLIC bool cwk_path_get_last_segment(const char *path,
386 struct cwk_segment *segment);
387
399
412
425 const struct cwk_segment *segment);
426
444CWK_PUBLIC size_t cwk_path_change_segment(struct cwk_segment *segment,
445 const char *value, char *buffer, size_t buffer_size);
446
458CWK_PUBLIC bool cwk_path_is_separator(const char *str);
459
470CWK_PUBLIC enum cwk_path_style cwk_path_guess_style(const char *path);
471
484
494
495#ifdef __cplusplus
496} // extern "C"
497#endif
498
499#endif
char const int length
Definition cJSON.h:169
char * buffer
Definition cJSON.h:169
CWK_PUBLIC size_t cwk_path_get_absolute(const char *base, const char *path, char *buffer, size_t buffer_size)
Generates an absolute path based on a base.
Definition cwalk.c:681
CWK_PUBLIC size_t cwk_path_change_basename(const char *path, const char *new_basename, char *buffer, size_t buffer_size)
Changes the basename of a file path.
Definition cwalk.c:972
#define CWK_PUBLIC
Definition cwalk.h:27
CWK_PUBLIC bool cwk_path_is_separator(const char *str)
Checks whether the submitted pointer points to a separator.
Definition cwalk.c:1344
CWK_PUBLIC size_t cwk_path_join(const char *path_a, const char *path_b, char *buffer, size_t buffer_size)
Joins two paths together.
Definition cwalk.c:860
CWK_PUBLIC enum cwk_path_style cwk_path_get_style(void)
Gets the path style configuration.
Definition cwalk.c:1475
CWK_PUBLIC size_t cwk_path_change_segment(struct cwk_segment *segment, const char *value, char *buffer, size_t buffer_size)
Changes the content of a segment.
Definition cwalk.c:1361
CWK_PUBLIC size_t cwk_path_get_relative(const char *base_directory, const char *path, char *buffer, size_t buffer_size)
Generates a relative path based on a base.
Definition cwalk.c:753
CWK_PUBLIC void cwk_path_set_style(enum cwk_path_style style)
Configures which path style is used.
Definition cwalk.c:1467
CWK_PUBLIC enum cwk_segment_type cwk_path_get_segment_type(const struct cwk_segment *segment)
Gets the type of the submitted path segment.
Definition cwalk.c:1330
CWK_PUBLIC bool cwk_path_get_next_segment(struct cwk_segment *segment)
Advances to the next segment.
Definition cwalk.c:1261
cwk_segment_type
Definition cwalk.h:58
@ CWK_CURRENT
Definition cwalk.h:60
@ CWK_BACK
Definition cwalk.h:61
@ CWK_NORMAL
Definition cwalk.h:59
CWK_PUBLIC bool cwk_path_get_previous_segment(struct cwk_segment *segment)
Moves to the previous segment.
Definition cwalk.c:1299
CWK_PUBLIC size_t cwk_path_normalize(const char *path, char *buffer, size_t buffer_size)
Creates a normalized version of the path.
Definition cwalk.c:1146
CWK_PUBLIC size_t cwk_path_change_root(const char *path, const char *new_root, char *buffer, size_t buffer_size)
Changes the root of a path.
Definition cwalk.c:895
CWK_PUBLIC bool cwk_path_get_first_segment(const char *path, struct cwk_segment *segment)
Gets the first segment of a path.
Definition cwalk.c:1227
CWK_PUBLIC enum cwk_path_style cwk_path_guess_style(const char *path)
Guesses the path style.
Definition cwalk.c:1414
CWK_PUBLIC void cwk_path_get_basename(const char *path, const char **basename, size_t *length)
Gets the basename of a file path.
Definition cwalk.c:947
CWK_PUBLIC bool cwk_path_has_extension(const char *path)
Determines whether the file path has an extension.
Definition cwalk.c:1066
CWK_PUBLIC size_t cwk_path_change_extension(const char *path, const char *new_extension, char *buffer, size_t buffer_size)
Changes the extension of a file path.
Definition cwalk.c:1075
CWK_PUBLIC bool cwk_path_is_absolute(const char *path)
Determine whether the path is absolute or not.
Definition cwalk.c:929
CWK_PUBLIC size_t cwk_path_get_intersection(const char *path_base, const char *path_other)
Finds common portions in two paths.
Definition cwalk.c:1158
CWK_PUBLIC bool cwk_path_get_extension(const char *path, const char **extension, size_t *length)
Gets the extension of a file path.
Definition cwalk.c:1038
CWK_PUBLIC bool cwk_path_is_relative(const char *path)
Determine whether the path is relative or not.
Definition cwalk.c:941
CWK_PUBLIC size_t cwk_path_join_multiple(const char **paths, char *buffer, size_t buffer_size)
Joins multiple paths together.
Definition cwalk.c:876
CWK_PUBLIC bool cwk_path_get_last_segment(const char *path, struct cwk_segment *segment)
Gets the last segment of the path.
Definition cwalk.c:1242
CWK_PUBLIC void cwk_path_get_root(const char *path, size_t *length)
Determines the root of a path.
Definition cwalk.c:884
CWK_PUBLIC void cwk_path_get_dirname(const char *path, size_t *length)
Gets the dirname of a file path.
Definition cwalk.c:1021
cwk_path_style
Determines the style which is used for the path parsing and generation.
Definition cwalk.h:69
@ CWK_STYLE_WINDOWS
Definition cwalk.h:70
@ CWK_STYLE_UNIX
Definition cwalk.h:71
Definition cwalk.h:41
const char * segments
Definition cwalk.h:43
const char * path
Definition cwalk.h:42
const char * begin
Definition cwalk.h:44
const char * end
Definition cwalk.h:45
size_t size
Definition cwalk.h:46