diff options
author | George Kadianakis <desnacked@gmail.com> | 2011-11-26 18:56:49 +0100 |
---|---|---|
committer | George Kadianakis <desnacked@gmail.com> | 2011-11-26 18:56:49 +0100 |
commit | f28014bf1aa4274a35404ccc37b559b5531f1835 (patch) | |
tree | f6cfc1f195d226034df81cb8ca85a210367f6e19 /src/common/util.h | |
parent | fa013e1bc520e116fa63729041e00546d6787dd8 (diff) | |
download | tor-f28014bf1aa4274a35404ccc37b559b5531f1835.tar.gz tor-f28014bf1aa4274a35404ccc37b559b5531f1835.zip |
Introduce write_bytes_to_new_file().
Introduce write_bytes_to_new_file(), a function which writes bytes to
a file only if that file did not exist.
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h index 77ed1ca5ee..79b641a014 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -315,6 +315,7 @@ int check_private_dir(const char *dirname, cpd_check_t check, const char *effective_user); #define OPEN_FLAGS_REPLACE (O_WRONLY|O_CREAT|O_TRUNC) #define OPEN_FLAGS_APPEND (O_WRONLY|O_CREAT|O_APPEND) +#define OPEN_FLAGS_DONT_REPLACE (O_CREAT|O_EXCL|O_APPEND|O_WRONLY) typedef struct open_file_t open_file_t; int start_writing_to_file(const char *fname, int open_flags, int mode, open_file_t **data_out); @@ -336,6 +337,8 @@ int write_chunks_to_file(const char *fname, const struct smartlist_t *chunks, int bin); int append_bytes_to_file(const char *fname, const char *str, size_t len, int bin); +int write_bytes_to_new_file(const char *fname, const char *str, size_t len, + int bin); /** Flag for read_file_to_str: open the file in binary mode. */ #define RFTS_BIN 1 |