-char *talloc_basename(const void *ctx, const char *dir)
-{
- char *p = strrchr(dir, '/');
-
- if (!p)
- return (char *)dir;
- return talloc_strdup(ctx, p+1);
-}
-
-char *talloc_dirname(const void *ctx, const char *dir)
-{
- char *p = strrchr(dir, '/');
-
- if (!p)
- return talloc_strdup(ctx, ".");
- return talloc_strndup(ctx, dir, p - dir);
-}
-
-char *talloc_getcwd(const void *ctx)
-{
- unsigned int len;
- char *cwd;
-
- /* *This* is why people hate C. */
- len = 32;
- cwd = talloc_array(ctx, char, len);
- while (!getcwd(cwd, len)) {
- if (errno != ERANGE) {
- talloc_free(cwd);
- return NULL;
- }
- cwd = talloc_realloc(ctx, cwd, char, len *= 2);
- }
- return cwd;
-}
-