init-db, clone: change unnecessary global into passed parameter
[git.git] / wrapper.h
blobf0c7d0616d6905c3c6b049262dbe56137be9fa8d
1 #ifndef WRAPPER_H
2 #define WRAPPER_H
4 /* set default permissions by passing mode arguments to open(2) */
5 int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
6 int git_mkstemp_mode(char *pattern, int mode);
8 ssize_t read_in_full(int fd, void *buf, size_t count);
9 ssize_t write_in_full(int fd, const void *buf, size_t count);
10 ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
12 static inline ssize_t write_str_in_full(int fd, const char *str)
14 return write_in_full(fd, str, strlen(str));
17 /**
18 * Open (and truncate) the file at path, write the contents of buf to it,
19 * and close it. Dies if any errors are encountered.
21 void write_file_buf(const char *path, const char *buf, size_t len);
23 /**
24 * Like write_file_buf(), but format the contents into a buffer first.
25 * Additionally, write_file() will append a newline if one is not already
26 * present, making it convenient to write text files:
28 * write_file(path, "counter: %d", ctr);
30 __attribute__((format (printf, 2, 3)))
31 void write_file(const char *path, const char *fmt, ...);
33 /* Return 1 if the file is empty or does not exists, 0 otherwise. */
34 int is_empty_or_missing_file(const char *filename);
36 #endif /* WRAPPER_H */