summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2005-07-24 17:12:26 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2005-07-24 17:12:26 +0000
commit0acbe3d54c03077d70d03ab15944074c073e9f93 (patch)
treedf4ea6fb9de71d055b48145aa67028c8c0709f6f /usr.bin
parent131f2d8109a59df1ebbe587ff88c349583ada1a3 (diff)
add cvs_unlink(); a wrapper to unlunk() w/ an error msg as it is used in
many places. Also handle -n and -t global options. ok joris@ jfb@.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/cvs.h3
-rw-r--r--usr.bin/cvs/util.c25
2 files changed, 26 insertions, 2 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index c0628f882dd..d34269b2352 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.72 2005/07/23 11:19:46 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.73 2005/07/24 17:12:25 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -397,6 +397,7 @@ 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_unlink (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 34e39313711..8dcc3aa30ff 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.39 2005/07/23 10:59:47 xsa Exp $ */
+/* $OpenBSD: util.c,v 1.40 2005/07/24 17:12:25 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -518,6 +518,29 @@ cvs_chdir(const char *path)
}
/*
+ * cvs_unlink()
+ *
+ * Removes the link named by <path>.
+ * unlink() wrapper with an error message.
+ * Returns 0 on success, or -1 on failure.
+ */
+int
+cvs_unlink(const char *path)
+{
+ cvs_log(LP_TRACE, "cvs_unlink(%s)", path);
+
+ if (cvs_noexec == 1)
+ return (0);
+
+ if (unlink(path) == -1) {
+ cvs_log(LP_ERRNO, "cannot remove `%s'", path);
+ return (-1);
+ }
+
+ return (0);
+}
+
+/*
* cvs_remove_dir()
*
* Remove a directory tree from disk.