ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
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 <stddef.h>
45#include <stdbool.h>
46
47#include "../common.h"
48
49/* ============================================================================
50 * Path Constants
51 * ============================================================================
52 */
53
59#define PATH_COMPONENT_DOT '.'
60
66#define PATH_COMPONENT_DOTDOT ".."
67
73#define PATH_TILDE '~'
74
78#define PATH_DRIVE_SEPARATOR ':'
79
85#define MAX_PATH_BASES 16
86
87/* ============================================================================
88 * Path Manipulation Functions
89 * ============================================================================
90 */
91
105const char *extract_project_relative_path(const char *file, const char *const *owned_dirs);
106
118const char *path_last_components(const char *path, size_t component_count);
119
140char *expand_path(const char *path);
141
171char *get_config_dir(void);
172
190char *get_data_dir(void);
191
227char *get_log_dir(void);
228
271
284bool path_normalize_copy(const char *path, char *out, size_t out_len);
285
292bool path_is_absolute(const char *path);
293
305bool path_is_within_base(const char *path, const char *base);
306
315bool path_is_within_any_base(const char *path, const char *const *bases, size_t base_count);
316
318 * @brief Classification for user-supplied filesystem paths.
319 */
320typedef enum {
327
338bool path_looks_like_path(const char *value);
339
364asciichat_error_t path_validate_user_path(const char *input, path_role_t role, char **normalized_out);
365
378
⚙️ Common definitions, error codes, macros, and types shared throughout the application
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
bool path_looks_like_path(const char *value)
Determine if a string is likely intended to reference the filesystem.
char * get_log_dir(void)
Get log directory path appropriate for current build type.
Definition path.c:291
path_role_t
Classification for user-supplied filesystem paths.
Definition path.h:318
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.
bool path_is_absolute(const char *path)
Determine whether a path is absolute on the current platform.
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:712
char * expand_path(const char *path)
Expand path with tilde (~) support.
Definition path.c:259
bool path_is_within_base(const char *path, const char *base)
Check whether a path resides within a specified base directory.
char * get_discovery_database_dir(void)
Get discovery service database directory with Homebrew-aware system-wide fallback.
Definition path.c:374
void path_cleanup_thread_locals(void)
Cleanup thread-local path resources.
const char * path_last_components(const char *path, size_t component_count)
Return a pointer to the last components of a path.
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:281
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.
char * get_data_dir(void)
Get application data directory path.
Definition path.c:286
bool path_normalize_copy(const char *path, char *out, size_t out_len)
Normalize a path and copy it into the provided buffer.
@ PATH_ROLE_CONFIG_FILE
Definition path.h:319
@ PATH_ROLE_CLIENT_KEYS
Definition path.h:323
@ PATH_ROLE_KEY_PUBLIC
Definition path.h:322
@ PATH_ROLE_LOG_FILE
Definition path.h:320
@ PATH_ROLE_KEY_PRIVATE
Definition path.h:321
static bool size_t gotel_query_t * out
Definition queries.h:8