summaryrefslogtreecommitdiffstats
path: root/source/lib/util.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-01-14 01:41:04 +0000
committerJeremy Allison <jra@samba.org>2000-01-14 01:41:04 +0000
commit38dffd360dc2e44bfc9e751f017e24f81ff0f2fa (patch)
treef29c9edb3d18eb8d569500710127df300f4768b8 /source/lib/util.c
parentf8bebf91abcaa5bda3ec8701f9242f220da8943a (diff)
downloadsamba-38dffd360dc2e44bfc9e751f017e24f81ff0f2fa.tar.gz
samba-38dffd360dc2e44bfc9e751f017e24f81ff0f2fa.tar.xz
samba-38dffd360dc2e44bfc9e751f017e24f81ff0f2fa.zip
Added "inherit permissions" patch.
Fixed locking bug found by Andrew. Jeremy.
Diffstat (limited to 'source/lib/util.c')
-rw-r--r--source/lib/util.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index a39dc1a516e..001baa0e3e3 100644
--- a/source/lib/util.c
+++ b/source/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;
+}