version 1.8, 2004/12/08 22:22:38 |
version 1.9, 2005/05/24 07:38:46 |
|
|
#include <errno.h> |
#include <errno.h> |
|
|
#include "buf.h" |
#include "buf.h" |
|
#include "cvs.h" |
#include "log.h" |
#include "log.h" |
|
|
|
|
|
|
{ |
{ |
int ret, fd; |
int ret, fd; |
|
|
|
ret = 0; |
|
|
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode); |
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode); |
if (fd == -1) { |
if (fd == -1) { |
cvs_log(LP_ERRNO, "failed to open file `%s': %s", |
cvs_log(LP_ERRNO, "failed to open file `%s': %s", |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
ret = cvs_buf_write_fd(b, fd); |
if (!cvs_noexec) |
|
ret = cvs_buf_write_fd(b, fd); |
|
|
if (ret == -1) { |
if (ret == -1) { |
cvs_log(LP_ERRNO, "failed to write to file `%s': %s", |
cvs_log(LP_ERRNO, "failed to write to file `%s': %s", |
path, strerror(errno)); |
path, strerror(errno)); |
|
|
{ |
{ |
int ret, fd; |
int ret, fd; |
|
|
|
ret = 0; |
|
|
fd = mkstemp(template); |
fd = mkstemp(template); |
if (fd == -1) { |
if (fd == -1) { |
cvs_log(LP_ERRNO, "failed to mkstemp file `%s': %s", |
cvs_log(LP_ERRNO, "failed to mkstemp file `%s': %s", |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
ret = cvs_buf_write_fd(b, fd); |
if (!cvs_noexec) |
|
ret = cvs_buf_write_fd(b, fd); |
|
|
if (ret == -1) { |
if (ret == -1) { |
cvs_log(LP_ERRNO, "failed to write to temp file `%s': %s", |
cvs_log(LP_ERRNO, "failed to write to temp file `%s': %s", |
template, strerror(errno)); |
template, strerror(errno)); |