json-gen-c  0.1.5
json-gen-c generate C code for json manipulation
io.h File Reference

File operation helper functions. More...

#include "utils/sstr.h"
Include dependency graph for io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int read_file (const char *filename, sstr_t content)
 Read the entire contents of a file into a string.
 
int write_file (const char *filename, sstr_t content)
 Write a string to a file, replacing any existing contents.
 

Detailed Description

File operation helper functions.

Function Documentation

◆ read_file()

int read_file ( const char *  filename,
sstr_t  content 
)
extern

Read the entire contents of a file into a string.

Parameters
filenamepath to the file to read.
contentoutput sstr_t that receives the file contents.
Returns
0 on success, non-zero on error (e.g. file not found).

◆ write_file()

int write_file ( const char *  filename,
sstr_t  content 
)
extern

Write a string to a file, replacing any existing contents.

Parameters
filenamepath to the file to write.
contentsstr_t containing the data to write.
Returns
0 on success, non-zero on error.