ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1#pragma once
2
43
44#include <stdbool.h>
45#include <stddef.h>
46
47#include "../common.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53/* ============================================================================
54 * Path Constants
55 * ============================================================================
56 */
57
63#define PATH_COMPONENT_DOT '.'
64
70#define PATH_COMPONENT_DOTDOT ".."
71
77#define PATH_TILDE '~'
78
82#define PATH_DRIVE_SEPARATOR ':'
83
89#define MAX_PATH_BASES 16
90
91/* ============================================================================
92 * Path Manipulation Functions
93 * ============================================================================
94 */
95
111const char *extract_project_relative_path(const char *file,
112 const char *const *owned_dirs);
113
125const char *path_last_components(const char *path, size_t component_count);
126
147char *expand_path(const char *path);
148
183char *get_config_dir(void);
184
202char *get_data_dir(void);
203
242char *get_log_dir(void);
243
294
308bool path_normalize_copy(const char *path, char *out, size_t out_len);
309
316bool path_is_absolute(const char *path);
317
329bool path_is_within_base(const char *path, const char *base);
330
339bool path_is_within_any_base(const char *path, const char *const *bases,
340 size_t base_count);
341
343 * @brief Classification for user-supplied filesystem paths.
344 */
345typedef enum {
352
363bool path_looks_like_path(const char *value);
364
392 char **normalized_out);
393
406
408
409#ifdef __cplusplus
410}
411#endif
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
bool path_looks_like_path(const char *value)
Determine if a string is likely intended to reference the filesystem.
Definition path.c:518
char * get_log_dir(void)
Get log directory path appropriate for current build type.
Definition path.c:303
path_role_t
Classification for user-supplied filesystem paths.
Definition path.h:343
const char * extract_project_relative_path(const char *file, const char *const *owned_dirs)
Extract a path relative to the source root embedded by CMake.
Definition path.c:137
bool path_is_absolute(const char *path)
Determine whether a path is absolute on the current platform.
Definition path.c:442
asciichat_error_t path_validate_user_path(const char *input, path_role_t role, char **normalized_out)
Validate and canonicalize a user-supplied filesystem path.
Definition path.c:739
char * expand_path(const char *path)
Expand path with tilde (~) support.
Definition path.c:270
bool path_is_within_base(const char *path, const char *base)
Check whether a path resides within a specified base directory.
Definition path.c:461
char * get_discovery_database_dir(void)
Get discovery service database directory with Homebrew-aware system-wide fallback.
Definition path.c:388
void path_cleanup_thread_locals(void)
Cleanup thread-local path resources.
Definition path.c:32
const char * path_last_components(const char *path, size_t component_count)
Return a pointer to the last components of a path.
Definition path.c:243
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:293
bool path_is_within_any_base(const char *path, const char *const *bases, size_t base_count)
Check whether a path resides within any of several base directories.
Definition path.c:499
char * get_data_dir(void)
Get application data directory path.
Definition path.c:298
bool path_normalize_copy(const char *path, char *out, size_t out_len)
Normalize a path and copy it into the provided buffer.
Definition path.c:422
@ PATH_ROLE_CONFIG_FILE
Definition path.h:344
@ PATH_ROLE_CLIENT_KEYS
Definition path.h:348
@ PATH_ROLE_KEY_PUBLIC
Definition path.h:347
@ PATH_ROLE_LOG_FILE
Definition path.h:345
@ PATH_ROLE_KEY_PRIVATE
Definition path.h:346
⚙️ Common definitions, error codes, macros, and types shared throughout the application
static bool size_t gotel_query_t * out
Definition queries.h:10