diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-07-23 10:49:36 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-07-23 10:49:36 +0000 |
commit | a5c25d0140b061a6d3a831d8ce48bce43b8835fc (patch) | |
tree | 17a233cf9b3434ae968f7455ec3fbd6aaa0983fc /usr.bin/cvs/util.c | |
parent | 228c8375dab6646ac58555c35269f2f85e6d5d41 (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@.
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r-- | usr.bin/cvs/util.c | 20 |
1 files changed, 19 insertions, 1 deletions
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. |