In the description of 3111908b034c73673a2f079b2b13a88c18379baa, it says that the functions must be able to handle st being NULL, but recurse always passes a valid pointer. The only function that was ever passed NULL was rm(), but this was changed to go through recurse in 2f4ab527391135e651b256f8654b050ea4a48f3d, so now the checks are pointless.
32 lines
675 B
C
32 lines
675 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <sys/stat.h>
|
|
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "../fs.h"
|
|
#include "../util.h"
|
|
|
|
int rm_status = 0;
|
|
|
|
void
|
|
rm(const char *path, struct stat *st, void *data, struct recursor *r)
|
|
{
|
|
if (!r->maxdepth && S_ISDIR(st->st_mode)) {
|
|
recurse(path, NULL, r);
|
|
|
|
if (rmdir(path) < 0) {
|
|
if (!(r->flags & SILENT))
|
|
weprintf("rmdir %s:", path);
|
|
if (!((r->flags & SILENT) && errno == ENOENT))
|
|
rm_status = 1;
|
|
}
|
|
} else if (unlink(path) < 0) {
|
|
if (!(r->flags & SILENT))
|
|
weprintf("unlink %s:", path);
|
|
if (!((r->flags & SILENT) && errno == ENOENT))
|
|
rm_status = 1;
|
|
}
|
|
}
|