ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1#pragma once
2
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
114const char *extract_project_relative_path(const char *file);
115
136char *expand_path(const char *path);
137
166char *get_config_dir(void);
167
203char *get_log_dir(void);
204
217bool path_normalize_copy(const char *path, char *out, size_t out_len);
218
225bool path_is_absolute(const char *path);
226
238bool path_is_within_base(const char *path, const char *base);
239
248bool path_is_within_any_base(const char *path, const char *const *bases, size_t base_count);
249
260
271bool path_looks_like_path(const char *value);
272
297asciichat_error_t path_validate_user_path(const char *input, path_role_t role, char **normalized_out);
298
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
bool path_looks_like_path(const char *value)
Determine if a string is likely intended to reference the filesystem.
Definition path.c:439
char * get_log_dir(void)
Get log directory path appropriate for current build type.
Definition path.c:277
path_role_t
Classification for user-supplied filesystem paths.
Definition path.h:253
bool path_is_absolute(const char *path)
Determine whether a path is absolute on the current platform.
Definition path.c:365
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:498
char * expand_path(const char *path)
Expand path with tilde (~) support.
Definition path.c:183
bool path_is_within_base(const char *path, const char *base)
Check whether a path resides within a specified base directory.
Definition path.c:383
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:223
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:421
const char * extract_project_relative_path(const char *file)
Extract relative path from an absolute path.
Definition path.c:127
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:346
@ PATH_ROLE_CONFIG_FILE
Definition path.h:254
@ PATH_ROLE_CLIENT_KEYS
Definition path.h:258
@ PATH_ROLE_KEY_PUBLIC
Definition path.h:257
@ PATH_ROLE_LOG_FILE
Definition path.h:255
@ PATH_ROLE_KEY_PRIVATE
Definition path.h:256