version 1.12, 2005/06/02 07:16:38 |
version 1.13, 2005/07/07 14:27:57 |
|
|
|
|
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'", path); |
cvs_log(LP_ERRNO, "failed to open file `%s'", path); |
return (-1); |
return (-1); |
} |
} |
|
|
|
|
/* |
/* |
* cvs_buf_write_stmp() |
* cvs_buf_write_stmp() |
* |
* |
* Write the contents of the buffer <b> to a temporary file whose path is |
* Write the contents of the buffer <b> to a temporary file whose path is |
* specified using <template> (see mkstemp.3). NB. This function will modify |
* specified using <template> (see mkstemp.3). NB. This function will modify |
* <template>, as per mkstemp |
* <template>, as per mkstemp |
*/ |
*/ |
|
|
|
|
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", |
template, strerror(errno)); |
template, strerror(errno)); |
return (-1); |
return (-1); |
} |
} |
|
|
ret = cvs_buf_write_fd(b, fd); |
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)); |
(void)unlink(template); |
(void)unlink(template); |
} |
} |