make_directories (char *file_name)
{
char *cursor0 = file_name + FILE_SYSTEM_PREFIX_LEN (file_name);
- char *cursor; /* points into the file name */
+ char *cursor; /* points into the file name */
int did_something = 0; /* did we do anything yet? */
int mode;
int invert_permissions;
int status;
-
for (cursor = cursor0; *cursor; cursor++)
{
if (! ISSLASH (*cursor))
apply_nonancestor_delayed_set_stat ("", 1);
}
+bool
+rename_directory (char *src, char *dst)
+{
+ if (rename (src, dst))
+ {
+ int e = errno;
+
+ switch (e)
+ {
+ case ENOENT:
+ if (make_directories (dst))
+ {
+ if (rename (src, dst) == 0)
+ return true;
+ e = errno;
+ }
+ break;
+
+ case EXDEV:
+ /* FIXME: Fall back to recursive copying */
+
+ default:
+ break;
+ }
+
+ ERROR ((0, e, _("Cannot rename %s to %s"),
+ quote_n (0, src),
+ quote_n (1, dst)));
+ return false;
+ }
+ return true;
+}
+
void
fatal_exit (void)
{