-char *tal_basename(const void *ctx, const char *dir)
-{
- const char *p = strrchr(dir, '/');
-
- if (!p)
- return tal_strdup(ctx, dir);
- return tal_strdup(ctx, p+1);
-}
-
-char *tal_dirname(const void *ctx, const char *dir)
-{
- const char *p = strrchr(dir, '/');
-
- if (!p)
- return tal_strdup(ctx, ".");
- return tal_strndup(ctx, dir, p - dir);
-}
-
-char *tal_getcwd(const void *ctx)
-{
- unsigned int len;
- char *cwd;
-
- /* *This* is why people hate C. */
- len = 32;
- cwd = tal_arr(ctx, char, len);
- while (!getcwd(cwd, len)) {
- if (errno != ERANGE) {
- tal_free(cwd);
- return NULL;
- }
- tal_resize(&cwd, len *= 2);
- }
- return cwd;
-}
-