+/* rb_basename
+ *
+ * input -
+ * output -
+ * side effects -
+ */
+char *
+rb_basename(const char *path)
+{
+ const char *s;
+
+ if(!(s = strrchr(path, '/')))
+ s = path;
+ else
+ s++;
+ return rb_strdup(s);
+}
+
+/*
+ * rb_dirname
+ */
+
+char *
+rb_dirname (const char *path)
+{
+ char *s;
+
+ s = strrchr(path, '/');
+ if(s == NULL)
+ {
+ return rb_strdup(".");
+ }
+
+ /* remove extra slashes */
+ while(s > path && *s == '/')
+ --s;
+
+ return rb_strndup(path, ((uintptr_t)s - (uintptr_t)path) + 2);
+}