--- /dev/null
+/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "abspath.h"
+
+#include <unistd.h>
+
+const char *t_abspath(const char *path)
+{
+ char dir[PATH_MAX];
+
+ if (*path == '/')
+ return path;
+
+ if (getcwd(dir, sizeof(dir)) == NULL)
+ i_fatal("getcwd() failed: %m");
+ return t_strconcat(dir, "/", path, NULL);
+}
+
+const char *t_abspath_to(const char *path, const char *root)
+{
+ if (*path == '/')
+ return path;
+
+ return t_strconcat(root, "/", path, NULL);
+}
--- /dev/null
+#ifndef ABSPATH_H
+#define ABSPATH_H
+
+/* Returns path as absolute path. If it's not already absolute path,
+ it's assumed to be relative to current working directory. */
+const char *t_abspath(const char *path);
+/* Like t_abspath(), but path is relative to given root. */
+const char *t_abspath_to(const char *path, const char *root);
+
+#endif