}
boolean forceOption = force.getValue();
boolean recurse = recursive.getValue();
UIPrompt prompt = context.getPrompt();
UIOutput output = context.getUIContext().getProvider().getOutput();
for (String file : arguments.getValue())
{
List<Resource<?>> resources = new PathspecParser(resourceFactory, currentResource, file).resolve();
for (Resource<?> resource : resources)
{
if ((resource instanceof DirectoryResource))
{
if (!recurse)
{
output.err().println(
"rm: cannot remove '" + resource.getName()
+ "': Is a directory ");
}
else if (!resource.listResources().isEmpty() && !forceOption)
{
output.err().println(
"rm: directory '" + resource.getName()
+ "' not empty and cannot be deleted without '--force' '-f' option.");
}
else if (forceOption || prompt.promptBoolean("Delete '" + resource.getFullyQualifiedName() + "'?"))
{
if (!resource.delete(recurse))
{
output.err().println("rm: cannot remove ‘" + resource.getFullyQualifiedName()
+ "’: Error occurred during deletion");
}
}
}
else
{
if (!resource.delete(recurse))
{
output.err().println("rm: cannot remove ‘" + resource.getFullyQualifiedName()
+ "’: Error occurred during deletion");
}
}
}