Add history and config-struct to recurse
For loop detection, a history is mandatory. In the process of also adding a flexible struct to recurse, the recurse-definition was moved to fs.h. The motivation behind the struct is to allow easy extensions to the recurse-function without having to change the prototypes of all functions in the process. Adding flags is really simple as well now. Using the recursor-struct, it's also easier to see which defaults apply to a program (for instance, which type of follow, ...). Another change was to add proper stat-lstat-usage in recurse. It was wrong before.
This commit is contained in:
4
mv.c
4
mv.c
@@ -12,6 +12,8 @@ static int mv_status = 0;
|
||||
static int
|
||||
mv(const char *s1, const char *s2, int depth)
|
||||
{
|
||||
struct recursor r = { .fn = rm, .hist = NULL, .depth = 0, .follow = 'P', .flags = 0};
|
||||
|
||||
if (!rename(s1, s2))
|
||||
return (mv_status = 0);
|
||||
if (errno == EXDEV) {
|
||||
@@ -19,7 +21,7 @@ mv(const char *s1, const char *s2, int depth)
|
||||
cp_HLPflag = 'P';
|
||||
rm_rflag = 1;
|
||||
cp(s1, s2, depth);
|
||||
rm(s1, 0, NULL);
|
||||
rm(s1, NULL, &r);
|
||||
return (mv_status = cp_status || rm_status);
|
||||
}
|
||||
mv_status = 1;
|
||||
|
Reference in New Issue
Block a user