24#ifdef HAVE_SYS_TYPES_H
46int tor_rename(
const char *path_old,
const char *path_new);
55typedef enum { FN_ERROR, FN_NOENT, FN_FILE, FN_DIR, FN_EMPTY }
file_status_t;
66#define OPEN_FLAGS_REPLACE (O_WRONLY|O_CREAT|O_TRUNC)
67#define OPEN_FLAGS_APPEND (O_WRONLY|O_CREAT|O_APPEND)
68#define OPEN_FLAGS_DONT_REPLACE (O_CREAT|O_EXCL|O_APPEND|O_WRONLY)
89int write_chunks_to_file(
const char *fname,
const struct smartlist_t *chunks,
90 int bin,
int no_tempfile);
101#define RFTS_IGNORE_MISSING 2
103MOCK_DECL_ATTR(
char *, read_file_to_str,(
const char *filename,
int flags,
104 struct stat *stat_out),
110#if !defined(HAVE_GETDELIM) || defined(TOR_UNIT_TESTS)
114ssize_t
compat_getdelim_(
char **lineptr,
size_t *n,
int delim, FILE *stream);
128#define tor_getdelim(lineptr, n, delim, stream) \
129 getdelim((lineptr), (n), (delim), (stream))
131#define tor_getdelim(lineptr, n, delim, stream) \
132 compat_getdelim_((lineptr), (n), (delim), (stream))
142#define tor_getline(lineptr, n, stream) \
143 getline((lineptr), (n), (stream))
145#define tor_getline(lineptr, n, stream) \
146 tor_getdelim((lineptr), (n), '\n', (stream))
Utility macros to handle different features and behavior in different compilers.
char * read_file_to_str_until_eof(int fd, size_t max_bytes_to_read, size_t *sz_out) ATTR_MALLOC
int write_str_to_file(const char *fname, const char *str, int bin)
ssize_t read_all_from_fd(int fd, char *buf, size_t count)
int tor_unlink(const char *pathname)
file_status_t file_status(const char *filename)
int finish_writing_to_file(open_file_t *file_data)
int write_bytes_to_new_file(const char *fname, const char *str, size_t len, int bin)
ssize_t compat_getdelim_(char **lineptr, size_t *n, int delim, FILE *stream)
int start_writing_to_file(const char *fname, int open_flags, int mode, open_file_t **data_out)
int tor_open_cloexec(const char *path, int flags, unsigned mode)
int touch_file(const char *fname)
ssize_t write_all_to_fd(int fd, const char *buf, size_t count)
int write_str_to_file_if_not_equal(const char *fname, const char *str)
int64_t tor_get_avail_disk_space(const char *path)
int append_bytes_to_file(const char *fname, const char *str, size_t len, int bin)
FILE * start_writing_to_stdio_file(const char *fname, int open_flags, int mode, open_file_t **data_out)
int replace_file(const char *from, const char *to)
int abort_writing_to_file(open_file_t *file_data)
int write_bytes_to_file(const char *fname, const char *str, size_t len, int bin)
FILE * tor_fopen_cloexec(const char *path, const char *mode)
int tor_rename(const char *path_old, const char *path_new)
bool is_file(file_status_t file_type)
FILE * fdopen_file(open_file_t *file_data)
bool is_dir(file_status_t file_type)
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
#define MOCK_DECL_ATTR(rv, funcname, arglist, attr)
Integer definitions used throughout Tor.