summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/file.c30
-rw-r--r--usr.bin/cvs/file.h5
2 files changed, 33 insertions, 2 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index c4b7b207f94..43276def939 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.21 2004/08/06 12:09:25 jfb Exp $ */
+/* $OpenBSD: file.c,v 1.22 2004/08/06 14:12:56 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -233,6 +233,7 @@ cvs_file_create(const char *path, u_int type, mode_t mode)
if (cfp == NULL)
return (NULL);
cfp->cf_type = type;
+ cfp->cf_mode = mode;
if (type == DT_DIR) {
if (mkdir(path, mode) == -1) {
@@ -347,6 +348,29 @@ cvs_file_find(CVSFILE *hier, const char *path)
/*
+ * cvs_file_attach()
+ *
+ * Attach the file <file> as one of the children of parent <parent>, which
+ * has to be a file of type DT_DIR.
+ * Returns 0 on success, or -1 on failure.
+ */
+
+int
+cvs_file_attach(CVSFILE *parent, CVSFILE *file)
+{
+
+ if (parent->cf_type != DT_DIR)
+ return (-1);
+
+ TAILQ_INSERT_HEAD(&(parent->cf_ddat->cd_files), file, cf_list);
+ parent->cf_ddat->cd_nfiles++;
+ file->cf_parent = parent;
+
+ return (0);
+}
+
+
+/*
* cvs_file_getdir()
*
* Get a cvs directory structure for the directory whose path is <dir>.
@@ -648,6 +672,8 @@ cvs_file_alloc(const char *path, u_int type)
* cvs_file_lget()
*
* Get the file and link it with the parent right away.
+ * Returns a pointer to the created file structure on success, or NULL on
+ * failure.
*/
static CVSFILE*
@@ -679,6 +705,8 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent)
return (NULL);
}
cfp->cf_parent = parent;
+ cfp->cf_mode = st.st_mode & ACCESSPERMS;
+ cfp->cf_mtime = st.st_mtime;
if ((parent != NULL) && (CVS_DIR_ENTRIES(parent) != NULL)) {
ent = cvs_ent_get(CVS_DIR_ENTRIES(parent), cfp->cf_name);
diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h
index ce48ecd0164..13c787b82b3 100644
--- a/usr.bin/cvs/file.h
+++ b/usr.bin/cvs/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.6 2004/08/06 12:09:26 jfb Exp $ */
+/* $OpenBSD: file.h,v 1.7 2004/08/06 14:12:56 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -75,6 +75,8 @@ typedef struct cvs_file {
char *cf_path;
struct cvs_file *cf_parent; /* parent directory (NULL if none) */
char *cf_name;
+ mode_t cf_mode;
+ time_t cf_mtime;
u_int16_t cf_cvstat; /* cvs status of the file */
u_int16_t cf_type; /* uses values from dirent.h */
struct cvs_dir *cf_ddat; /* only for directories */
@@ -111,6 +113,7 @@ CVSFILE* cvs_file_create (const char *, u_int, mode_t);
CVSFILE* cvs_file_get (const char *, int);
CVSFILE* cvs_file_getspec (char **, int, int);
CVSFILE* cvs_file_find (CVSFILE *, const char *);
+int cvs_file_attach (CVSFILE *, CVSFILE *);
int cvs_file_examine (CVSFILE *, int (*)(CVSFILE *, void *), void *);
void cvs_file_free (struct cvs_file *);