ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
filesystem.c File Reference

Go to the source code of this file.

Functions

FILE * platform_fopen (const char *name, const char *filename, const char *mode)
FILE * platform_tmpfile (void)
int platform_mkdir_recursive (const char *path, int mode)
int platform_find_config_file (const char *filename, config_file_list_t *list_out)
void config_file_list_destroy (config_file_list_t *list)
ssize_t platform_read (int fd, void *buf, size_t count)
int platform_open (const char *name, const char *pathname, int flags,...)
int platform_close (int fd)
int platform_access (const char *pathname, int mode)
char * platform_get_data_dir (void)
int platform_get_data_dir_candidates (const char *install_prefix, platform_directory_list_t *list_out)

Function Documentation

◆ config_file_list_destroy()

void config_file_list_destroy ( config_file_list_t * list)

Definition at line 52 of file filesystem.c.

52 {
53 (void)list;
54 // No-op
55}

Referenced by check_known_host_with_key(), and config_load_system_and_user().

◆ platform_access()

int platform_access ( const char * pathname,
int mode )

Definition at line 95 of file filesystem.c.

95 {
96 (void)pathname;
97 (void)mode;
98 return -1; // Not accessible in WASM
99}

Referenced by config_load_and_apply(), discovery_session_create(), get_discovery_database_dir(), get_log_dir(), parse_mirror_media(), update_check_load_cache(), update_check_perform(), and websocket_server_init().

◆ platform_close()

◆ platform_find_config_file()

int platform_find_config_file ( const char * filename,
config_file_list_t * list_out )

Definition at line 42 of file filesystem.c.

42 {
43 (void)filename;
44 if (list_out) {
45 list_out->files = NULL;
46 list_out->count = 0;
47 list_out->capacity = 0;
48 }
49 return ASCIICHAT_OK; // No config files in WASM
50}
@ ASCIICHAT_OK
Definition error_codes.h:50

References ASCIICHAT_OK.

Referenced by check_known_host_with_key(), and config_load_system_and_user().

◆ platform_fopen()

FILE * platform_fopen ( const char * name,
const char * filename,
const char * mode )

Definition at line 18 of file filesystem.c.

18 {
19 if (!name) {
20 return NULL;
21 }
22 FILE *stream = fopen(filename, mode); // Use standard fopen
23 if (stream) {
24 int fd = fileno(stream);
25 if (fd >= 0) {
26 NAMED_REGISTER_FD(fd, name);
27 }
28 }
29 return stream;
30}
#define NAMED_REGISTER_FD(fd, name)
Register an existing file descriptor.

References NAMED_REGISTER_FD.

Referenced by acds_identity_load(), action_completions(), add_known_host(), colorscheme_export_scheme(), config_create_default(), discovery_keys_save_cached(), get_manpage_template(), gpg_sign_with_key(), options_config_generate_manpage_template(), parse_keys_from_file(), parse_manpage_sections(), parse_private_key(), parse_public_key(), ui_notice_first_use_complete(), update_check_load_cache(), update_check_save_cache(), validate_ssh_key_file(), and wav_writer_open().

◆ platform_get_data_dir()

char * platform_get_data_dir ( void )

Definition at line 101 of file filesystem.c.

101 {
102 return NULL; // No data directory in WASM
103}

Referenced by get_data_dir(), and mcp_server_main().

◆ platform_get_data_dir_candidates()

int platform_get_data_dir_candidates ( const char * install_prefix,
platform_directory_list_t * list_out )

Definition at line 105 of file filesystem.c.

105 {
106 (void)install_prefix;
107 if (!list_out) {
108 return SET_ERRNO(ERROR_INVALID_PARAM, "list_out cannot be NULL");
109 }
110 list_out->candidates = NULL;
111 list_out->count = 0;
112 return ASCIICHAT_OK;
113}
#define SET_ERRNO(code,...)
@ ERROR_INVALID_PARAM

References ASCIICHAT_OK, ERROR_INVALID_PARAM, and SET_ERRNO.

Referenced by get_discovery_database_dir().

◆ platform_mkdir_recursive()

int platform_mkdir_recursive ( const char * path,
int mode )

Definition at line 36 of file filesystem.c.

36 {
37 (void)path;
38 (void)mode;
39 return ERROR_PLATFORM_INIT; // Not implemented for WASM
40}
@ ERROR_PLATFORM_INIT
Definition error_codes.h:59

References ERROR_PLATFORM_INIT.

Referenced by acds_identity_save(), config_create_default(), discovery_keys_save_cached(), get_discovery_database_dir(), and mcp_server_main().

◆ platform_open()

int platform_open ( const char * name,
const char * pathname,
int flags,
... )

Definition at line 65 of file filesystem.c.

65 {
66 if (!name) {
67 return -1;
68 }
69
70 // Handle optional mode parameter for O_CREAT
71 int fd = -1;
72 int mode = 0;
73 if (flags & 0x0200) { // O_CREAT flag value
74 va_list args;
75 va_start(args, flags);
76 mode = va_arg(args, int);
77 va_end(args);
78 fd = open(pathname, flags, mode);
79 } else {
80 fd = open(pathname, flags);
81 }
82
83 if (fd >= 0) {
84 NAMED_REGISTER_FD(fd, name);
85 log_dev("Opened file descriptor %d for %s at path %s", fd, name, pathname);
86 }
87
88 return fd;
89}
#define log_dev(...)
Log a DEV message (most verbose, development only).
Definition log/log.h:575
action_args_t args

References args, log_dev, and NAMED_REGISTER_FD.

Referenced by acds_identity_save(), action_create_manpage(), check_known_host_no_identity(), check_known_host_with_key(), log_init(), main(), parse_gpg_keys_from_response(), remove_known_host(), and test_logging_disable().

◆ platform_read()

ssize_t platform_read ( int fd,
void * buf,
size_t count )

Definition at line 61 of file filesystem.c.

61 {
62 return read(fd, buf, count);
63}

◆ platform_tmpfile()

FILE * platform_tmpfile ( void )

Definition at line 32 of file filesystem.c.

32 {
33 return tmpfile();
34}

Referenced by log_io_start(), and manpage_parser_parse_memory().