version 1.35, 2005/06/02 20:19:30 |
version 1.36, 2005/06/07 07:23:41 |
|
|
cvs_ent_open(const char *dir, int flags) |
cvs_ent_open(const char *dir, int flags) |
{ |
{ |
size_t len; |
size_t len; |
int exists; |
int exists, nodir; |
char entpath[MAXPATHLEN], ebuf[128], mode[4]; |
char cdpath[MAXPATHLEN], entpath[MAXPATHLEN], ebuf[128], mode[4]; |
FILE *fp; |
FILE *fp; |
struct stat st; |
struct stat st; |
struct cvs_ent *ent; |
struct cvs_ent *ent; |
CVSENTRIES *ep; |
CVSENTRIES *ep; |
|
|
exists = 0; |
exists = 0; |
|
nodir = 1; |
memset(mode, 0, sizeof(mode)); |
memset(mode, 0, sizeof(mode)); |
|
|
|
/* |
|
* Check if the CVS/ dir does exist. If it does, |
|
* maybe the Entries file was deleted by accident, |
|
* display error message. Else we might be doing a fresh |
|
* update or checkout of a module. |
|
*/ |
|
len = cvs_path_cat(dir, CVS_PATH_CVSDIR, cdpath, sizeof(cdpath)); |
|
if (len >= sizeof(cdpath)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", cdpath); |
|
return (NULL); |
|
} |
|
if ((stat(cdpath, &st) == 0) && S_ISDIR(st.st_mode)) |
|
nodir = 0; /* the CVS/ directory does exist */ |
|
|
len = cvs_path_cat(dir, CVS_PATH_ENTRIES, entpath, sizeof(entpath)); |
len = cvs_path_cat(dir, CVS_PATH_ENTRIES, entpath, sizeof(entpath)); |
if (len >= sizeof(entpath)) |
if (len >= sizeof(entpath)) |
return (NULL); |
return (NULL); |
|
|
|
|
fp = fopen(entpath, mode); |
fp = fopen(entpath, mode); |
if (fp == NULL) { |
if (fp == NULL) { |
cvs_log(LP_ERRNO, "cannot open %s for %s", entpath, |
if (!nodir) |
mode[1] == '+' ? "writing" : "reading"); |
cvs_log(LP_ERRNO, "cannot open %s for %s", entpath, |
|
mode[1] == '+' ? "writing" : "reading"); |
return (NULL); |
return (NULL); |
} |
} |
|
|