ascii-chat 0.11.33
Video chat in your terminal
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
167char *get_config_dir(void);
168
186char *get_data_dir(void);
187
223char *get_log_dir(void);
224
267
280bool path_normalize_copy(const char *path, char *out, size_t out_len);
281
288bool path_is_absolute(const char *path);
289
301bool path_is_within_base(const char *path, const char *base);
302
311bool path_is_within_any_base(const char *path, const char *const *bases, size_t base_count);
312
323
334bool path_looks_like_path(const char *value);
335
360asciichat_error_t path_validate_user_path(const char *input, path_role_t role, char **normalized_out);
361
374
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
bool path_looks_like_path(const char *value)
Determine if a string is likely intended to reference the filesystem.
Definition path.c:809
char * get_log_dir(void)
Get log directory path appropriate for current build type.
Definition path.c:537
path_role_t
Classification for user-supplied filesystem paths.
Definition path.h:316
bool path_is_absolute(const char *path)
Determine whether a path is absolute on the current platform.
Definition path.c:739
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:1020
char * expand_path(const char *path)
Expand path with tilde (~) support.
Definition path.c:505
bool path_is_within_base(const char *path, const char *base)
Check whether a path resides within a specified base directory.
Definition path.c:757
char * get_discovery_database_dir(void)
Get discovery service database directory with Homebrew-aware system-wide fallback.
Definition path.c:624
void path_cleanup_thread_locals(void)
Cleanup thread-local path resources.
Definition path.c:85
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:527
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:791
char * get_data_dir(void)
Get application data directory path.
Definition path.c:532
const char * extract_project_relative_path(const char *file)
Extract relative path from an absolute path.
Definition path.c:456
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:719
@ PATH_ROLE_CONFIG_FILE
Definition path.h:317
@ PATH_ROLE_CLIENT_KEYS
Definition path.h:321
@ PATH_ROLE_KEY_PUBLIC
Definition path.h:320
@ PATH_ROLE_LOG_FILE
Definition path.h:318
@ PATH_ROLE_KEY_PRIVATE
Definition path.h:319
ClangTool/LibTooling compatibility shim for stdbool.h.