version 1.12, 2005/03/30 17:43:04 |
version 1.13, 2005/04/03 17:32:50 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <string.h> |
#include <string.h> |
#include <sysexits.h> |
|
|
|
#include "cvs.h" |
#include "cvs.h" |
#include "rcs.h" |
#include "rcs.h" |
|
|
* cvs_init_local() |
* cvs_init_local() |
* |
* |
* Local handler for the "cvs init" command. |
* Local handler for the "cvs init" command. |
* Returns 0 on success, or the appropriate exit status on failure. |
* Returns 0 on success, -1 on failure. |
*/ |
*/ |
int |
int |
cvs_init_local(struct cvsroot *root) |
cvs_init_local(struct cvsroot *root) |
|
|
if (mkdir(path, cvsroot_files[i].cf_mode) == -1) { |
if (mkdir(path, cvsroot_files[i].cf_mode) == -1) { |
cvs_log(LP_ERRNO, "failed to create `%s'", |
cvs_log(LP_ERRNO, "failed to create `%s'", |
path); |
path); |
return (EX_CANTCREAT); |
return (-1); |
} |
} |
} else if (cvsroot_files[i].cf_type == CFT_FILE) { |
} else if (cvsroot_files[i].cf_type == CFT_FILE) { |
fd = open(path, O_WRONLY|O_CREAT|O_EXCL, |
fd = open(path, O_WRONLY|O_CREAT|O_EXCL, |
|
|
if (fd == -1) { |
if (fd == -1) { |
cvs_log(LP_ERRNO, "failed to create `%s'", |
cvs_log(LP_ERRNO, "failed to create `%s'", |
path); |
path); |
return (EX_CANTCREAT); |
return (-1); |
} |
} |
|
|
(void)close(fd); |
(void)close(fd); |
|
|
strlcat(path, RCS_FILE_EXT, sizeof(path)); |
strlcat(path, RCS_FILE_EXT, sizeof(path)); |
rfp = rcs_open(path, RCS_WRITE|RCS_CREATE, 0640); |
rfp = rcs_open(path, RCS_WRITE|RCS_CREATE, 0640); |
if (rfp == NULL) { |
if (rfp == NULL) { |
return (EX_CANTCREAT); |
return (-1); |
} |
} |
|
|
rcs_close(rfp); |
rcs_close(rfp); |