From 3a6c2069d77176bfa2b379ef711034396c477791 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Jan 2000 01:41:04 +0000 Subject: Added "inherit permissions" patch. Fixed locking bug found by Andrew. Jeremy. (This used to be commit 38dffd360dc2e44bfc9e751f017e24f81ff0f2fa) --- source3/lib/util.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index a39dc1a516..001baa0e3e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3280,3 +3280,31 @@ char *lock_path(char *name) return fname; } + +/******************************************************************* + Given a filename - get its directory name + NB: Returned in static storage. Caveats: + o Not safe in thread environment. + o Caller must not free. + o If caller wishes to preserve, they should copy. +********************************************************************/ + +char *parent_dirname(const char *path) +{ + static pstring dirpath; + char *p; + + if (!path) + return(NULL); + + pstrcpy(dirpath, path); + p = strrchr(dirpath, '/'); /* Find final '/', if any */ + if (!p) { + pstrcpy(dirpath, "."); /* No final "/", so dir is "." */ + } else { + if (p == dirpath) + ++p; /* For root "/", leave "/" in place */ + *p = '\0'; + } + return dirpath; +} -- cgit