version 1.90, 2005/06/17 15:09:55 |
version 1.91, 2005/07/01 08:59:09 |
|
|
|
|
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
cf->cf_root = cvsroot_get(fpath); |
cf->cf_root = cvsroot_get(fpath); |
if (cf->cf_root == NULL) |
if (cf->cf_root == NULL) { |
|
/* |
|
* Do not fail here for an unknown directory. |
|
*/ |
|
if (cf->cf_cvstat == CVS_FST_UNKNOWN) |
|
return (0); |
return (-1); |
return (-1); |
|
} |
|
|
if (flags & CF_MKADMIN) |
if (flags & CF_MKADMIN) |
cvs_mkadmin(fpath, cf->cf_root->cr_str, NULL); |
cvs_mkadmin(fpath, cf->cf_root->cr_str, NULL); |
|
|
static int |
static int |
cvs_file_getdir(CVSFILE *cf, int flags, char *path, int (*cb)(CVSFILE *, void *), void *arg) |
cvs_file_getdir(CVSFILE *cf, int flags, char *path, int (*cb)(CVSFILE *, void *), void *arg) |
{ |
{ |
int l; |
int l, ret; |
int check_entry; |
int check_entry; |
u_int ndirs, nfiles; |
u_int ndirs, nfiles; |
char *cur, *np; |
char *cur, *np; |
|
|
DIR *dirp; |
DIR *dirp; |
CVSENTRIES *entfile; |
CVSENTRIES *entfile; |
|
|
|
ret = -1; |
check_entry = 1; |
check_entry = 1; |
ndirs = nfiles = 0; |
ndirs = nfiles = 0; |
SIMPLEQ_INIT(&dirs); |
SIMPLEQ_INIT(&dirs); |
|
|
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
entfile = cvs_ent_open(fpath, O_RDONLY); |
|
|
|
cf->cf_root = cvsroot_get(fpath); |
|
if (cf->cf_root == NULL) |
|
return (-1); |
|
|
|
cur = np = NULL; |
cur = np = NULL; |
if (path != NULL) { |
if (path != NULL) { |
cur = strchr(path, '/'); |
cur = strchr(path, '/'); |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
|
cf->cf_root = cvsroot_get(fpath); |
|
if (cf->cf_root == NULL) { |
|
/* |
|
* Do not fail here for an unknown directory. |
|
*/ |
|
if (cf->cf_cvstat == CVS_FST_UNKNOWN) |
|
return (0); |
|
return (-1); |
|
} |
|
|
dirp = opendir(fpath); |
dirp = opendir(fpath); |
if (dirp == NULL) { |
if (dirp == NULL) { |
cvs_log(LP_ERRNO, "failed to open directory %s", fpath); |
cvs_log(LP_ERRNO, "failed to open directory %s", fpath); |
return (-1); |
return (-1); |
} |
} |
|
|
|
entfile = cvs_ent_open(fpath, O_RDONLY); |
while ((ent = readdir(dirp)) != NULL) { |
while ((ent = readdir(dirp)) != NULL) { |
if ((flags & CF_IGNORE) && cvs_file_chkign(ent->d_name)) |
if ((flags & CF_IGNORE) && cvs_file_chkign(ent->d_name)) |
continue; |
continue; |
|
|
errno = ENAMETOOLONG; |
errno = ENAMETOOLONG; |
cvs_log(LP_ERRNO, "%s", pbuf); |
cvs_log(LP_ERRNO, "%s", pbuf); |
closedir(dirp); |
closedir(dirp); |
return (-1); |
goto done; |
} |
} |
|
|
cfp = cvs_file_find(cf, ent->d_name); |
cfp = cvs_file_find(cf, ent->d_name); |
|
|
|
|
if (cfp == NULL) { |
if (cfp == NULL) { |
closedir(dirp); |
closedir(dirp); |
return (-1); |
goto done; |
} |
} |
if (entfile != NULL) |
if (entfile != NULL) |
cvs_ent_remove(entfile, cfp->cf_name); |
cvs_ent_remove(entfile, cfp->cf_name); |
|
|
if (cb != NULL) { |
if (cb != NULL) { |
if (cb(cfp, arg) != CVS_EX_OK) { |
if (cb(cfp, arg) != CVS_EX_OK) { |
closedir(dirp); |
closedir(dirp); |
return (-1); |
goto done; |
} |
} |
} |
} |
} |
} |
|
|
if (l == -1 || l >= (int)sizeof(pbuf)) { |
if (l == -1 || l >= (int)sizeof(pbuf)) { |
errno = ENAMETOOLONG; |
errno = ENAMETOOLONG; |
cvs_log(LP_ERRNO, "%s", pbuf); |
cvs_log(LP_ERRNO, "%s", pbuf); |
return (-1); |
goto done; |
} |
} |
|
|
cfp = cvs_file_find(cf, cvsent->ce_name); |
cfp = cvs_file_find(cf, cvsent->ce_name); |
|
|
/* callback for the file */ |
/* callback for the file */ |
if (cb != NULL) { |
if (cb != NULL) { |
if (cb(cfp, arg) != CVS_EX_OK) |
if (cb(cfp, arg) != CVS_EX_OK) |
return (-1); |
goto done; |
} |
} |
} |
} |
|
|
if (path != NULL) |
if (path != NULL) |
break; |
break; |
} |
} |
cvs_ent_close(entfile); |
|
} |
} |
|
|
if (flags & CF_SORT) { |
if (flags & CF_SORT) { |
|
|
} |
} |
} |
} |
|
|
return (0); |
ret = 0; |
|
done: |
|
if (entfile != NULL) |
|
cvs_ent_close(entfile); |
|
|
|
return (ret); |
} |
} |
|
|
|
|
|
|
|
|
cfp = cvs_file_find(cvs_files, fpath); |
cfp = cvs_file_find(cvs_files, fpath); |
if (cfp == NULL) |
if (cfp == NULL) |
|
continue; |
|
|
|
/* ignore unknown directories */ |
|
if (cfp->cf_cvstat == CVS_FST_UNKNOWN) |
continue; |
continue; |
|
|
if (cvs_file_prune(fpath)) { |
if (cvs_file_prune(fpath)) { |