summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2005-07-23 10:49:36 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2005-07-23 10:49:36 +0000
commita5c25d0140b061a6d3a831d8ce48bce43b8835fc (patch)
tree17a233cf9b3434ae968f7455ec3fbd6aaa0983fc
parent228c8375dab6646ac58555c35269f2f85e6d5d41 (diff)
add cvs_chdir(); a wrapper to chdir() w/ an error msg as it is used in
many places. Let's make our life simpler for once. ok jfb@ joris@.
-rw-r--r--usr.bin/cvs/cvs.h3
-rw-r--r--usr.bin/cvs/util.c20
2 files changed, 21 insertions, 2 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index ffa322ec40d..5df82557544 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.70 2005/07/21 09:51:07 xsa Exp $ */
+/* $OpenBSD: cvs.h,v 1.71 2005/07/23 10:49:35 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -396,6 +396,7 @@ int cvs_mkadmin (const char *, const char *, const char *);
int cvs_cksum (const char *, char *, size_t);
int cvs_exec (int, char **, int []);
int cvs_getargv (const char *, char **, int);
+int cvs_chdir (const char *);
int cvs_remove_dir (const char *);
int cvs_create_dir (const char *, int, char *, char *);
char* cvs_rcs_getpath (CVSFILE *, char *, size_t);
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 799e9fd6794..e983df8dbbb 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.37 2005/07/19 15:36:54 xsa Exp $ */
+/* $OpenBSD: util.c,v 1.38 2005/07/23 10:49:35 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -500,6 +500,24 @@ cvs_exec(int argc, char **argv, int fds[3])
}
/*
+ * cvs_chdir()
+ *
+ * Change to directory.
+ * chdir() wrapper with an error message.
+ * Returns 0 on success, or -1 on failure.
+ */
+int
+cvs_chdir(const char *path)
+{
+ if (chdir(path) == -1) {
+ cvs_log(LP_ERRNO, "cannot change to dir `%s'", path);
+ return (-1);
+ }
+
+ return (0);
+}
+
+/*
* cvs_remove_dir()
*
* Remove a directory tree from disk.