version 1.34, 2004/11/26 16:23:50 |
version 1.35, 2004/12/02 06:54:15 |
|
|
char fp[MAXPATHLEN]; |
char fp[MAXPATHLEN]; |
CVSFILE *cfp; |
CVSFILE *cfp; |
|
|
printf("cvs_file_create(%s)\n", path); |
|
cfp = cvs_file_alloc(path, type); |
cfp = cvs_file_alloc(path, type); |
if (cfp == NULL) |
if (cfp == NULL) |
return (NULL); |
return (NULL); |
|
|
cfp->cf_type = type; |
|
cfp->cf_mode = mode; |
cfp->cf_mode = mode; |
cfp->cf_parent = parent; |
cfp->cf_parent = parent; |
|
|
|
|
|
|
|
|
/* |
/* |
|
* cvs_file_copy() |
|
* |
|
* Allocate space to create a copy of the file <orig>. The copy inherits all |
|
* of the original's attributes, but does not inherit its children if the |
|
* original file is a directory. Note that files copied using this mechanism |
|
* are linked to their parent, but the parent has no link to the file. This |
|
* is so cvs_file_getpath() works. |
|
* Returns the copied file on success, or NULL on failure. The returned |
|
* structure should be freed using cvs_file_free(). |
|
*/ |
|
|
|
CVSFILE* |
|
cvs_file_copy(CVSFILE *orig) |
|
{ |
|
char path[MAXPATHLEN]; |
|
CVSFILE *cfp; |
|
|
|
cvs_file_getpath(orig, path, sizeof(path)); |
|
|
|
cfp = cvs_file_alloc(path, orig->cf_type); |
|
if (cfp == NULL) |
|
return (NULL); |
|
|
|
cfp->cf_parent = orig->cf_parent; |
|
cfp->cf_mode = orig->cf_mode; |
|
cfp->cf_mtime = orig->cf_mtime; |
|
cfp->cf_cvstat = orig->cf_cvstat; |
|
|
|
if (orig->cf_type == DT_DIR) { |
|
/* XXX copy CVS directory attributes */ |
|
} |
|
|
|
return (cfp); |
|
} |
|
|
|
|
|
/* |
* cvs_file_get() |
* cvs_file_get() |
* |
* |
* Load a cvs_file structure with all the information pertaining to the file |
* Load a cvs_file structure with all the information pertaining to the file |
|
|
|
|
cfp->cf_name = cvs_file_getname(fnp); |
cfp->cf_name = cvs_file_getname(fnp); |
if (cfp->cf_name == NULL) { |
if (cfp->cf_name == NULL) { |
cvs_log(LP_ERR, "WTF!?"); |
cvs_log(LP_ERR, "failed to get file name from table"); |
return (NULL); |
return (NULL); |
} |
} |
cfp->cf_type = type; |
cfp->cf_type = type; |
|
|
cfp->cf_cvstat = CVS_FST_ADDED; |
cfp->cf_cvstat = CVS_FST_ADDED; |
else { |
else { |
/* check last modified time */ |
/* check last modified time */ |
if (ent->ce_mtime == st.st_mtime) |
if (ent->ce_mtime == (time_t)st.st_mtime) |
cfp->cf_cvstat = CVS_FST_UPTODATE; |
cfp->cf_cvstat = CVS_FST_UPTODATE; |
else |
else |
cfp->cf_cvstat = CVS_FST_MODIFIED; |
cfp->cf_cvstat = CVS_FST_MODIFIED; |