version 1.15, 2004/12/08 20:00:23 |
version 1.16, 2004/12/10 18:47:38 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <string.h> |
#include <string.h> |
|
#include <libgen.h> |
#include <sysexits.h> |
#include <sysexits.h> |
|
|
#include "buf.h" |
#include "buf.h" |
|
|
static int |
static int |
cvs_resp_copyfile(struct cvsroot *root, int type, char *line) |
cvs_resp_copyfile(struct cvsroot *root, int type, char *line) |
{ |
{ |
char newname[MAXNAMLEN]; |
char path[MAXPATHLEN], newpath[MAXPATHLEN], newname[MAXNAMLEN], *file; |
|
|
/* read the new file name given by the server */ |
/* read the remote path of the file to copy and its new name */ |
if (cvs_getln(root, newname, sizeof(newname)) < 0) |
if ((cvs_getln(root, path, sizeof(path)) < 0) || |
|
(cvs_getln(root, newname, sizeof(newname)) < 0)) |
return (-1); |
return (-1); |
|
|
if (rename(line, newname) == -1) { |
if ((file = basename(path)) == NULL) { |
|
cvs_log(LP_ERR, "no base file name in Copy-file path"); |
|
return (-1); |
|
} |
|
|
|
snprintf(path, sizeof(path), "%s%s", line, file); |
|
snprintf(newpath, sizeof(newpath), "%s%s", line, newname); |
|
|
|
if (rename(path, newpath) == -1) { |
cvs_log(LP_ERRNO, "failed to rename %s to %s", line, newname); |
cvs_log(LP_ERRNO, "failed to rename %s to %s", line, newname); |
return (-1); |
return (-1); |
} |
} |