+#if 0
+/* Remove directory entry for the given CANAME */
+void
+remove_directory (const char *caname)
+{
+ struct directory *dir = make_directory (caname, xstrdup (caname));
+ struct directory *ret = hash_delete (directory_table, dir);
+ if (ret)
+ free_directory (ret);
+ free_directory (dir);
+}
+#endif
+
+/* Find a directory entry for NAME. If first OLD_PREFIX_LEN
+ bytes of its name match OLD_PREFIX, replace them with
+ NEW_PREFIX. */
+void
+rebase_directory (const char *name, size_t old_prefix_len,
+ const char *old_prefix,
+ const char *new_prefix)
+{
+ struct directory *dir = find_directory (name);
+ if (dir)
+ {
+ size_t len = strlen (dir->name);
+ if (len > old_prefix_len
+ && memcmp (dir->name, old_prefix, old_prefix_len) == 0)
+ {
+ char *newp = xmalloc (len - old_prefix_len + strlen (new_prefix));
+ strcpy (newp, new_prefix);
+ strcat (newp, dir->name + old_prefix_len);
+ free (dir->name);
+ dir->name = newp;
+ }
+ }
+}
+