| 4026 | ///////////////////////////////////////////////////////////////////////////// |
| 4027 | |
| 4028 | FILE *fopen_replace(const char *name) |
| 4029 | { |
| 4030 | int fd; |
| 4031 | |
| 4032 | // Stave off symlink attacks. Races will be handled with O_EXCL. |
| 4033 | unlink_u(name); |
| 4034 | fd = open_u(name, O_CREAT|O_EXCL|O_WRONLY, 0666); |
| 4035 | if (fd == -1) |
| 4036 | return 0; |
| 4037 | return fdopen(fd, "w"); |
| 4038 | } |
| 4039 | |
| 4040 | // Returns the size of the opened file with the give FILE* handle. |
| 4041 | off_t file_size(FILE *handle) |
no test coverage detected