1 package ch
.cyberduck
.core
.ftp
;
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
20 import ch
.cyberduck
.core
.LoginCallback
;
21 import ch
.cyberduck
.core
.Path
;
22 import ch
.cyberduck
.core
.exception
.BackgroundException
;
23 import ch
.cyberduck
.core
.features
.Delete
;
25 import java
.io
.IOException
;
26 import java
.util
.List
;
31 public class FTPDeleteFeature
implements Delete
{
33 private FTPSession session
;
35 public FTPDeleteFeature(final FTPSession session
) {
36 this.session
= session
;
40 public void delete(final List
<Path
> files
, final LoginCallback prompt
, final Callback callback
) throws BackgroundException
{
41 for(Path file
: files
) {
42 callback
.delete(file
);
44 if(file
.isFile() || file
.isSymbolicLink()) {
45 if(!session
.getClient().deleteFile(file
.getAbsolute())) {
46 throw new FTPException(session
.getClient().getReplyCode(), session
.getClient().getReplyString());
49 else if(file
.isDirectory()) {
50 if(!session
.getClient().removeDirectory(file
.getAbsolute())) {
51 throw new FTPException(session
.getClient().getReplyCode(), session
.getClient().getReplyString());
55 catch(IOException e
) {
56 throw new FTPExceptionMappingService().map("Cannot delete {0}", e
, file
);