+/** Use slash as directory separator. On Windows, they can pretty
+ much be exchanged. */
+#if 0
+static /* avoid warning */
+#endif
+string
+slashify (string file_name)
+{
+ replace_all (&file_name, '\\', '/');
+ replace_all (&file_name, string ("//"), "/");
+ return file_name;
+}
+
+string
+dir_name (string const file_name)
+{
+ string s = file_name;
+ s = slashify (s);
+ ssize n = s.length ();
+ if (n && s[n - 1] == '/')
+ s[n - 1] = 0;
+ if (s.rfind ('/') != NPOS)
+ s = s.substr (0, s.rfind ('/'));
+ else
+ s = "";
+
+ return s;
+}
+
+string
+get_working_directory ()
+{
+ char cwd[PATH_MAX];
+ // getcwd returns NULL upon a failure, contents of cwd would be undefined!
+ return string (getcwd (cwd, PATH_MAX));
+}
+