Merge pull request #64 in ITERATE/cyberduck from feature/windows/9074 to master
[cyberduck.git] / source / ch / cyberduck / core / dav / DAVDirectoryFeature.java
blobbb71a2f67caffb36922418b45a84248b8ece83ce
1 package ch.cyberduck.core.dav;
3 /*
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
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.DefaultIOExceptionMappingService;
21 import ch.cyberduck.core.Path;
22 import ch.cyberduck.core.exception.BackgroundException;
23 import ch.cyberduck.core.features.Directory;
25 import java.io.IOException;
27 import com.github.sardine.impl.SardineException;
29 /**
30 * @version $Id$
32 public class DAVDirectoryFeature implements Directory {
34 private DAVSession session;
36 public DAVDirectoryFeature(final DAVSession session) {
37 this.session = session;
40 @Override
41 public void mkdir(final Path file) throws BackgroundException {
42 this.mkdir(file, null);
45 @Override
46 public void mkdir(final Path file, final String region) throws BackgroundException {
47 try {
48 session.getClient().createDirectory(new DAVPathEncoder().encode(file));
50 catch(SardineException e) {
51 throw new DAVExceptionMappingService().map("Cannot create folder {0}", e, file);
53 catch(IOException e) {
54 throw new DefaultIOExceptionMappingService().map(e, file);