version 1.50, 2005/01/11 00:01:14 |
version 1.51, 2005/01/12 20:10:09 |
|
|
#include <errno.h> |
#include <errno.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
#include <libgen.h> |
#include <dirent.h> |
#include <dirent.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
CVSFILE* |
CVSFILE* |
cvs_file_alloc(const char *path, u_int type) |
cvs_file_alloc(const char *path, u_int type) |
{ |
{ |
size_t len; |
|
char pbuf[MAXPATHLEN]; |
|
const char *fnp; |
|
CVSFILE *cfp; |
CVSFILE *cfp; |
struct cvs_dir *ddat; |
struct cvs_dir *ddat; |
|
|
|
|
} |
} |
memset(cfp, 0, sizeof(*cfp)); |
memset(cfp, 0, sizeof(*cfp)); |
|
|
/* ditch trailing slashes */ |
cfp->cf_name = cvs_file_getname(basename(path)); |
strlcpy(pbuf, path, sizeof(pbuf)); |
|
len = strlen(pbuf); |
|
while (pbuf[len - 1] == '/') |
|
pbuf[--len] = '\0'; |
|
|
|
fnp = strrchr(path, '/'); |
|
if (fnp == NULL) |
|
fnp = path; |
|
else |
|
fnp++; |
|
|
|
cfp->cf_name = cvs_file_getname(fnp); |
|
if (cfp->cf_name == NULL) { |
if (cfp->cf_name == NULL) { |
cvs_log(LP_ERR, "failed to get file name from table"); |
cvs_log(LP_ERR, "failed to get file name from table"); |
return (NULL); |
return (NULL); |