diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-12-28 21:50:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:16:46 -0500 |
commit | 98c082489bec0a0ce4db1daf4390e785381f229a (patch) | |
tree | e0872d7bdb525991311bab54137208381a58c223 /source3/lib | |
parent | 143a364d6253125c27e229d533940a6822ce7575 (diff) | |
download | samba-98c082489bec0a0ce4db1daf4390e785381f229a.tar.gz samba-98c082489bec0a0ce4db1daf4390e785381f229a.tar.bz2 samba-98c082489bec0a0ce4db1daf4390e785381f229a.zip |
r20394: This is a *VERY* early start of my work on notify.
Checking in because Jeremy was bugging me. Potentially this becomes quite
intrusive, I'm not sure if I should open a temporary branch for this.
Jeremy, Jerry, do you think 3_0 is the right place for this?
Volker
(This used to be commit bcf5c751cbe203c00814642e26440cf88f300bce)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 9ac0b37612..5e2588e5b9 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2620,6 +2620,37 @@ char *parent_dirname(const char *path) return dirpath; } +BOOL parent_dirname_talloc(TALLOC_CTX *mem_ctx, const char *dir, + char **parent, const char **name) +{ + char *p; + ptrdiff_t len; + + p = strrchr_m(dir, '/'); /* Find final '/', if any */ + + if (p == NULL) { + if (!(*parent = talloc_strdup(mem_ctx, "."))) { + return False; + } + if (name) { + *name = ""; + } + return True; + } + + len = p-dir; + + if (!(*parent = TALLOC_ARRAY(mem_ctx, char, len+1))) { + return False; + } + memcpy(*parent, dir, len); + (*parent)[len] = '\0'; + + if (name) { + *name = p+1; + } + return True; +} /******************************************************************* Determine if a pattern contains any Microsoft wildcard characters. |