public void makeDir(String path) throws IOException { makeDir(path, FileAttributes.EMPTY); }
public void mkdir(String dirname) throws IOException { engine.makeDir(dirname); }
private boolean makeDirIfNotExists(final String remote) throws IOException { try { FileAttributes attrs = engine.stat(remote); if (attrs.getMode().getType() != FileMode.Type.DIRECTORY) { throw new IOException(remote + " exists and should be a directory, but was a " + attrs.getMode().getType()); } // Was not created, but existed. return false; } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("makeDir: {} does not exist, creating", remote); engine.makeDir(remote); return true; } else { throw e; } } }
@Test public void doesNotTryToCreateDirectoryTwiceWhenPathHasTrailingSeparator() throws Exception { SFTPClient client = new SFTPClient(sftpEngine); client.mkdirs("/folder/directory/"); verify(sftpEngine, times(1)).makeDir("/folder/directory"); } }
public void makeDir(String path) throws IOException { makeDir(path, FileAttributes.EMPTY); }
public void mkdir(String dirname) throws IOException { engine.makeDir(dirname); }
public void mkdir(String dirname) throws IOException { engine.makeDir(dirname); }
public void makeDir(String path) throws IOException { makeDir(path, FileAttributes.EMPTY); }
private boolean makeDirIfNotExists(final String remote) throws IOException { try { FileAttributes attrs = engine.stat(remote); if (attrs.getMode().getType() != FileMode.Type.DIRECTORY) { throw new IOException(remote + " exists and should be a directory, but was a " + attrs.getMode().getType()); } // Was not created, but existed. return false; } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("makeDir: {} does not exist, creating", remote); engine.makeDir(remote); return true; } else { throw e; } } }
private String prepareDir(final LocalSourceFile local, final String remote) throws IOException { final FileAttributes attrs; try { attrs = engine.stat(remote); } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("probeDir: {} does not exist, creating", remote); engine.makeDir(remote); return remote; } else throw e; } if (attrs.getMode().getType() == FileMode.Type.DIRECTORY) if (engine.getPathHelper().getComponents(remote).getName().equals(local.getName())) { log.debug("probeDir: {} already exists", remote); return remote; } else { log.debug("probeDir: {} already exists, path adjusted for {}", remote, local.getName()); return prepareDir(local, engine.getPathHelper().adjustForParent(remote, local.getName())); } else throw new IOException(attrs.getMode().getType() + " file already exists at " + remote); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs; if(Permission.EMPTY != status.getPermission()) { attrs = new FileAttributes.Builder().withPermissions(Integer.parseInt(status.getPermission().getMode(), 8)).build(); } else { attrs = FileAttributes.EMPTY; } session.sftp().makeDir(folder.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new SFTPAttributesFinderFeature(session).find(folder)); }