mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
Add a write_bytes_to_file so we can have files with NULs in them.
svn:r2662
This commit is contained in:
parent
451f8b5045
commit
d5244e3872
@ -756,6 +756,13 @@ int check_private_dir(const char *dirname, int create)
|
||||
*/
|
||||
int
|
||||
write_str_to_file(const char *fname, const char *str, int bin)
|
||||
{
|
||||
return write_bytes_to_file(fname, str, strlen(str), bin);
|
||||
}
|
||||
|
||||
/* DOCDOC */
|
||||
int write_bytes_to_file(const char *fname, const char *str, size_t len,
|
||||
int bin)
|
||||
{
|
||||
char tempname[1024];
|
||||
int fd;
|
||||
@ -772,7 +779,6 @@ write_str_to_file(const char *fname, const char *str, int bin)
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
len = strlen(str);
|
||||
result = write_all(fd, str, len, 0);
|
||||
if(result < 0 || (size_t)result != len) {
|
||||
log(LOG_WARN, "Error writing to %s: %s", tempname, strerror(errno));
|
||||
|
@ -88,6 +88,8 @@ file_status_t file_status(const char *filename);
|
||||
|
||||
int check_private_dir(const char *dirname, int create);
|
||||
int write_str_to_file(const char *fname, const char *str, int bin);
|
||||
int write_bytes_to_file(const char *fname, const char *str, size_t len,
|
||||
int bin);
|
||||
char *read_file_to_str(const char *filename, int bin);
|
||||
int parse_line_from_file(char *line, size_t maxlen, FILE *f, char **key_out, char **value_out);
|
||||
char *expand_filename(const char *filename);
|
||||
|
Loading…
Reference in New Issue
Block a user