Mail Archives: djgpp-workers/2003/08/03/07:18:26
> From: "Andrew Cottrell" <AndrewCottrell AT swiftdsl DOT com DOT au>
> Date: Sun, 3 Aug 2003 17:21:11 +1000
>
> The initial call to rename and _rename are okay, but after the return from
> _rename() the recusive issue strikes. After the return from _rename() the
> directory result is 100% perfect.
There shouldn't be any recursive calls; see below.
> I have further traced the problem to the following line in rename(). Before
> the call all is okay, but after the recusive junk1/junk1/junk1 exists....
> /* Process all of its siblings. */
> retval = __file_tree_walk(source, mover);
This is a bug, I think: on Windows, there should be no need to do this
file-tree traversal, since Windows can move a directory with all its
files and subdirectories in one go. `rename' has code to see if a
simple call to `_rename' succeeds, and only do the recursive thing if
it doesn't. Only plain DOS needs the recursive renaming, IIRC.
Furthermore, there should be code _before_ the call to `_rename' that
detects the fact that you are trying to move a directory into its own
subdirectory, and refuse to do so. Here's that code, I think:
else if ((source_attr & 0x10) == 0x10)
{
/* Fail to rename OLD -> OLD/whatever. */
char new_true[FILENAME_MAX], old_true[FILENAME_MAX];
errno = 0;
if (is_parent(_truename(old, old_true), _truename(new, new_true)))
{
errno = EINVAL;
return -1;
}
else if (errno)
return -1;
}
Now, this `is_parent' thing depends heavily on what `_truename'
returns for each of the two file names, so perhaps it's `_truename'
that messes up the code on XP. Or maybe there's some simple bug in
the case that `whatever' is the same string as OLD.
Finally, I still don't understand how come `mv' did say "cannot move
`junk1' to a subdirectory of itself": that seems to suggest that it
correctly diagnosed the problem and refused to move the file, no?
Last, but not least, thanks for working on this.
- Raw text -