ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
filesystem.c File Reference

File operation stubs for WASM. More...

Go to the source code of this file.

Functions

FILE * platform_fopen (const char *filename, const char *mode)
 
FILE * platform_tmpfile (void)
 
size_t platform_write_all (int fd, const void *buf, size_t count)
 
asciichat_error_t platform_mkdir_recursive (const char *path, int mode)
 
asciichat_error_t 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_write (int fd, const void *buf, size_t count)
 
ssize_t platform_read (int fd, void *buf, size_t count)
 
int platform_open (const char *pathname, int flags,...)
 
int platform_close (int fd)
 
int platform_access (const char *pathname, int mode)
 
char * platform_get_data_dir (void)
 

Detailed Description

File operation stubs for WASM.

Definition in file wasm/stubs/filesystem.c.

Function Documentation

◆ config_file_list_destroy()

void config_file_list_destroy ( config_file_list_t *  list)

Definition at line 49 of file wasm/stubs/filesystem.c.

49 {
50 (void)list;
51 // No-op
52}

Referenced by check_known_host(), and config_load_system_and_user().

◆ platform_access()

int platform_access ( const char *  pathname,
int  mode 
)

Definition at line 87 of file wasm/stubs/filesystem.c.

87 {
88 (void)pathname;
89 (void)mode;
90 return -1; // Not accessible in WASM
91}

Referenced by get_discovery_database_dir(), and get_log_dir().

◆ platform_close()

◆ platform_find_config_file()

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

Definition at line 39 of file wasm/stubs/filesystem.c.

39 {
40 (void)filename;
41 if (list_out) {
42 list_out->files = NULL;
43 list_out->count = 0;
44 list_out->capacity = 0;
45 }
46 return ASCIICHAT_OK; // No config files in WASM
47}

Referenced by check_known_host(), and config_load_system_and_user().

◆ platform_fopen()

◆ platform_get_data_dir()

char * platform_get_data_dir ( void  )

Definition at line 93 of file wasm/stubs/filesystem.c.

93 {
94 return NULL; // No data directory in WASM
95}

Referenced by get_data_dir().

◆ platform_mkdir_recursive()

asciichat_error_t platform_mkdir_recursive ( const char *  path,
int  mode 
)

Definition at line 33 of file wasm/stubs/filesystem.c.

33 {
34 (void)path;
35 (void)mode;
36 return ERROR_PLATFORM_INIT; // Not implemented for WASM
37}

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

◆ platform_open()

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

Definition at line 70 of file wasm/stubs/filesystem.c.

70 {
71 // Handle optional mode parameter for O_CREAT
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 return open(pathname, flags, mode);
79 }
80 return open(pathname, flags);
81}
action_args_t args

References args.

Referenced by acds_identity_save(), check_known_host(), check_known_host_no_identity(), 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 66 of file wasm/stubs/filesystem.c.

66 {
67 return read(fd, buf, count);
68}

◆ platform_tmpfile()

FILE * platform_tmpfile ( void  )

Definition at line 22 of file wasm/stubs/filesystem.c.

22 {
23 return tmpfile();
24}

Referenced by manpage_parser_parse_memory().

◆ platform_write()

ssize_t platform_write ( int  fd,
const void *  buf,
size_t  count 
)

Definition at line 55 of file wasm/stubs/filesystem.c.

55 {
56 // For WASM, route stdout/stderr to browser console
57 if ((fd == 1 || fd == 2) && buf && count > 0) {
58 wasm_log_to_console(fd, (const uint8_t *)buf, count);
59 return (ssize_t)count; // Report all bytes as written
60 }
61
62 // Fallback: use standard write for other fds
63 return write(fd, buf, count);
64}
void wasm_log_to_console(int fd, const uint8_t *buf, size_t count)
Definition console.c:99

References wasm_log_to_console().

Referenced by log_json_write(), and platform_write_all().

◆ platform_write_all()

size_t platform_write_all ( int  fd,
const void *  buf,
size_t  count 
)

Definition at line 26 of file wasm/stubs/filesystem.c.

26 {
27 (void)fd;
28 (void)buf;
29 (void)count;
30 return 0; // Not implemented for WASM
31}