2012-01-30 17:41:33 -05:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
2015-03-01 17:48:50 -05:00
|
|
|
#include <errno.h>
|
2012-01-30 17:41:33 -05:00
|
|
|
#include <stdio.h>
|
2013-03-05 15:46:48 -05:00
|
|
|
|
2012-01-30 17:41:33 -05:00
|
|
|
#include "../fs.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
2014-11-13 15:24:47 -05:00
|
|
|
int rm_fflag = 0;
|
|
|
|
int rm_rflag = 0;
|
2015-01-30 06:45:54 -05:00
|
|
|
int rm_status = 0;
|
2012-01-30 17:41:33 -05:00
|
|
|
|
|
|
|
void
|
2015-03-11 18:21:52 -04:00
|
|
|
rm(const char *path, int depth, void *data)
|
2012-01-30 17:41:33 -05:00
|
|
|
{
|
2014-11-13 13:54:28 -05:00
|
|
|
if (rm_rflag)
|
2015-03-11 18:21:52 -04:00
|
|
|
recurse(path, rm, depth, NULL);
|
2015-01-30 06:45:54 -05:00
|
|
|
if (remove(path) < 0) {
|
|
|
|
if (!rm_fflag)
|
|
|
|
weprintf("remove %s:", path);
|
2015-03-02 04:53:55 -05:00
|
|
|
if (!(rm_fflag && errno == ENOENT))
|
|
|
|
rm_status = 1;
|
2015-01-30 06:45:54 -05:00
|
|
|
}
|
2012-01-30 17:41:33 -05:00
|
|
|
}
|