24#ifdef HAVE_SYS_TYPES_H
50int tor_rename(
const char *path_old,
const char *path_new);
59typedef enum { FN_ERROR, FN_NOENT, FN_FILE, FN_DIR, FN_EMPTY }
file_status_t;
70#define OPEN_FLAGS_REPLACE (O_WRONLY|O_CREAT|O_TRUNC)
71#define OPEN_FLAGS_APPEND (O_WRONLY|O_CREAT|O_APPEND)
72#define OPEN_FLAGS_DONT_REPLACE (O_CREAT|O_EXCL|O_APPEND|O_WRONLY)
93int write_chunks_to_file(
const char *fname,
const struct smartlist_t *chunks,
94 int bin,
int no_tempfile);
105#define RFTS_IGNORE_MISSING 2
107MOCK_DECL_ATTR(
char *, read_file_to_str,(
const char *filename,
int flags,
108 struct stat *stat_out),
114#if !defined(HAVE_GETDELIM) || defined(TOR_UNIT_TESTS)
118ssize_t
compat_getdelim_(
char **lineptr,
size_t *n,
int delim, FILE *stream);
132#define tor_getdelim(lineptr, n, delim, stream) \
133 getdelim((lineptr), (n), (delim), (stream))
135#define tor_getdelim(lineptr, n, delim, stream) \
136 compat_getdelim_((lineptr), (n), (delim), (stream))
146#define tor_getline(lineptr, n, stream) \
147 getline((lineptr), (n), (stream))
149#define tor_getline(lineptr, n, stream) \
150 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.