congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SFTPEngine.getPathHelper
Code IndexAdd Tabnine to your IDE (free)

How to use
getPathHelper
method
in
net.schmizz.sshj.sftp.SFTPEngine

Best Java code snippets using net.schmizz.sshj.sftp.SFTPEngine.getPathHelper (Showing top 18 results out of 315)

origin: hierynomus/sshj

private synchronized String cwdify(String path) {
  return engine.getPathHelper().adjustForParent(cwd, path);
}
origin: hierynomus/sshj

public void mkdirs(String path)
    throws IOException {
  final Deque<String> dirsToMake = new LinkedList<String>();
  for (PathComponents current = engine.getPathHelper().getComponents(path); ;
     current = engine.getPathHelper().getComponents(current.getParent())) {
    final FileAttributes attrs = statExistence(current.getPath());
    if (attrs == null) {
      dirsToMake.push(current.getPath());
    } else if (attrs.getType() != FileMode.Type.DIRECTORY) {
      throw new SFTPException(current.getPath() + " exists but is not a directory");
    } else {
      break;
    }
  }
  while (!dirsToMake.isEmpty()) {
    mkdir(dirsToMake.pop());
  }
}
origin: hierynomus/sshj

@Override
public void download(String source, LocalDestFile dest) throws IOException {
  final PathComponents pathComponents = engine.getPathHelper().getComponents(source);
  final FileAttributes attributes = engine.stat(source);
  new Downloader().download(getTransferListener(), new RemoteResourceInfo(pathComponents, attributes), dest);
}
origin: hierynomus/sshj

private String uploadDir(final TransferListener listener,
             final LocalSourceFile local,
             final String remote)
    throws IOException {
  makeDirIfNotExists(remote);
  for (LocalSourceFile f : local.getChildren(getUploadFilter()))
    upload(listener, f, engine.getPathHelper().adjustForParent(remote, f.getName()));
  return remote;
}
origin: hierynomus/sshj

@Before
public void setPathHelper() throws Exception {
  PathHelper helper = new PathHelper(new PathHelper.Canonicalizer() {
    /**
     * Very basic, it does not try to canonicalize relative bits in the middle of a path.
     */
    @Override
    public String canonicalize(String path)
        throws IOException {
      if ("".equals(path) || ".".equals(path) || "./".equals(path))
        return "/home/me";
      if ("..".equals(path) || "../".equals(path))
        return "/home";
      return path;
    }
  }, DEFAULT_PATH_SEPARATOR);
  when(sftpEngine.getPathHelper()).thenReturn(helper);
  when(sftpEngine.stat("/")).thenReturn(new FileAttributes.Builder().withType(FileMode.Type.DIRECTORY).build());
  when(sftpEngine.getLoggerFactory()).thenReturn(LoggerFactory.DEFAULT);
}
origin: hierynomus/sshj

final PathComponents comps = requester.getPathHelper().getComponents(path, name);
final RemoteResourceInfo inf = new RemoteResourceInfo(comps, attrs);
if (!(".".equals(name) || "..".equals(name)) && (filter == null || filter.accept(inf))) {
origin: hierynomus/sshj

private void upload(final TransferListener listener) throws IOException {
  if (source.isDirectory()) {
    makeDirIfNotExists(remote); // Ensure that the directory exists
    uploadDir(listener.directory(source.getName()), source, remote);
    setAttributes(source, remote);
  } else if (source.isFile() && isDirectory(remote)) {
    String adjustedRemote = engine.getPathHelper().adjustForParent(this.remote, source.getName());
    uploadFile(listener.file(source.getName(), source.getLength()), source, adjustedRemote);
    setAttributes(source, adjustedRemote);
  } else if (source.isFile()) {
    uploadFile(listener.file(source.getName(), source.getLength()), source, remote);
    setAttributes(source, remote);
  } else {
    throw new IOException(source + " is not a file or directory");
  }
}
origin: com.hierynomus/sshj

private synchronized String cwdify(String path) {
  return engine.getPathHelper().adjustForParent(cwd, path);
}
origin: net.schmizz/sshj

private synchronized String cwdify(String path) {
  return engine.getPathHelper().adjustForParent(cwd, path);
}
origin: net.schmizz/sshj

public void mkdirs(String path)
    throws IOException {
  final Deque<String> dirsToMake = new LinkedList<String>();
  for (PathComponents current = engine.getPathHelper().getComponents(path); ;
     current = engine.getPathHelper().getComponents(current.getParent())) {
    final FileAttributes attrs = statExistence(current.getPath());
    if (attrs == null) {
      dirsToMake.push(current.getPath());
    } else if (attrs.getType() != FileMode.Type.DIRECTORY) {
      throw new SFTPException(current.getPath() + " exists but is not a directory");
    } else {
      break;
    }
  }
  while (!dirsToMake.isEmpty()) {
    mkdir(dirsToMake.pop());
  }
}
origin: com.hierynomus/sshj

public void mkdirs(String path)
    throws IOException {
  final Deque<String> dirsToMake = new LinkedList<String>();
  for (PathComponents current = engine.getPathHelper().getComponents(path); ;
     current = engine.getPathHelper().getComponents(current.getParent())) {
    final FileAttributes attrs = statExistence(current.getPath());
    if (attrs == null) {
      dirsToMake.push(current.getPath());
    } else if (attrs.getType() != FileMode.Type.DIRECTORY) {
      throw new SFTPException(current.getPath() + " exists but is not a directory");
    } else {
      break;
    }
  }
  while (!dirsToMake.isEmpty()) {
    mkdir(dirsToMake.pop());
  }
}
origin: net.schmizz/sshj

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);
}
origin: net.schmizz/sshj

private String prepareFile(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("probeFile: {} does not exist", remote);
      return remote;
    } else
      throw e;
  }
  if (attrs.getMode().getType() == FileMode.Type.DIRECTORY) {
    log.debug("probeFile: {} was directory, path adjusted for {}", remote, local.getName());
    return engine.getPathHelper().adjustForParent(remote, local.getName());
  } else {
    log.debug("probeFile: {} is a {} file that will be replaced", remote, attrs.getMode().getType());
    return remote;
  }
}
origin: com.hierynomus/sshj

private String uploadDir(final TransferListener listener,
             final LocalSourceFile local,
             final String remote)
    throws IOException {
  makeDirIfNotExists(remote);
  for (LocalSourceFile f : local.getChildren(getUploadFilter()))
    upload(listener, f, engine.getPathHelper().adjustForParent(remote, f.getName()));
  return remote;
}
origin: net.schmizz/sshj

@Override
public void download(String source, LocalDestFile dest)
    throws IOException {
  final PathComponents pathComponents = engine.getPathHelper().getComponents(source);
  final FileAttributes attributes = engine.stat(source);
  new Downloader().download(getTransferListener(), new RemoteResourceInfo(pathComponents, attributes), dest);
}
origin: com.hierynomus/sshj

@Override
public void download(String source, LocalDestFile dest) throws IOException {
  final PathComponents pathComponents = engine.getPathHelper().getComponents(source);
  final FileAttributes attributes = engine.stat(source);
  new Downloader().download(getTransferListener(), new RemoteResourceInfo(pathComponents, attributes), dest);
}
origin: com.hierynomus/sshj

final PathComponents comps = requester.getPathHelper().getComponents(path, name);
final RemoteResourceInfo inf = new RemoteResourceInfo(comps, attrs);
if (!(".".equals(name) || "..".equals(name)) && (filter == null || filter.accept(inf))) {
origin: com.hierynomus/sshj

private void upload(final TransferListener listener) throws IOException {
  if (source.isDirectory()) {
    makeDirIfNotExists(remote); // Ensure that the directory exists
    uploadDir(listener.directory(source.getName()), source, remote);
    setAttributes(source, remote);
  } else if (source.isFile() && isDirectory(remote)) {
    String adjustedRemote = engine.getPathHelper().adjustForParent(this.remote, source.getName());
    uploadFile(listener.file(source.getName(), source.getLength()), source, adjustedRemote);
    setAttributes(source, adjustedRemote);
  } else if (source.isFile()) {
    uploadFile(listener.file(source.getName(), source.getLength()), source, remote);
    setAttributes(source, remote);
  } else {
    throw new IOException(source + " is not a file or directory");
  }
}
net.schmizz.sshj.sftpSFTPEnginegetPathHelper

Popular methods of SFTPEngine

  • open
  • makeDir
  • stat
  • <init>
  • canonicalize
  • close
  • getOperativeProtocolVersion
  • getSubsystem
  • init
  • lstat
  • openDir
  • readLink
  • openDir,
  • readLink,
  • remove,
  • removeDir,
  • rename,
  • request,
  • setAttributes,
  • symlink,
  • doRequest

Popular in Java

  • Running tasks concurrently on multiple threads
  • notifyDataSetChanged (ArrayAdapter)
  • startActivity (Activity)
  • setScale (BigDecimal)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JLabel (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now