ch.cyberduck.core.Path.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中ch.cyberduck.core.Path.getParent()方法的一些代码示例,展示了Path.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.getParent()方法的具体详情如下:
包路径:ch.cyberduck.core.Path
类名称:Path
方法名:getParent

Path.getParent介绍

暂无

代码示例

代码示例来源:origin: iterate-ch/cyberduck

/**
   * @param changed Changed files and directories
   * @return Set of parent folders to reload
   */
  public Set<Path> find(final List<Path> changed) {
    final Set<Path> folders = new HashSet<Path>();
    for(Path file : changed) {
      folders.add(file.getParent());
    }
    return folders;
  }
}

代码示例来源:origin: iterate-ch/cyberduck

public Path find(final Path selected) {
    if(null == selected) {
      return workdir;
    }
    if(selected.getType().contains(Path.Type.volume)) {
      return selected;
    }
    return selected.getParent();
  }
}

代码示例来源:origin: iterate-ch/cyberduck

public boolean isContainer(final Path file) {
  if(file.isRoot()) {
    return false;
  }
  return file.getParent().isRoot();
}

代码示例来源:origin: iterate-ch/cyberduck

protected void setObjectValueForItem(final Path item, final NSObject value, final String identifier) {
  if(log.isDebugEnabled()) {
    log.debug(String.format("Set new value %s for item %s", value, item));
  }
  if(identifier.equals(BrowserColumn.filename.name())) {
    if(StringUtils.isNotBlank(value.toString()) && !item.getName().equals(value.toString())) {
      final Path renamed = new Path(item.getParent(), value.toString(), item.getType(), item.attributes());
      new MoveController(controller).rename(item, renamed);
    }
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
  public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) {
    if(StringUtils.containsAny(remote.getName(), '*')) {
      // Treat asterisk as wildcard
      return Collections.singleton(new TransferItem(remote.getParent()));
    }
    return Collections.singleton(new TransferItem(remote));
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
  public Path find(final Path root, final String path) {
    final Path home = super.find(root, path);
    if(containerService.isContainer(home)) {
      return new Path(home.getParent(), home.getName(), EnumSet.of(Path.Type.volume, Path.Type.directory));
    }
    return home;
  }
}

代码示例来源:origin: iterate-ch/cyberduck

private Path getWorkdirFromSelection() {
  if(this.getSelectionCount() == 1) {
    final Path selected = this.getSelectedPath();
    if(null != selected) {
      return selected.getParent();
    }
  }
  return this.workdir();
}

代码示例来源:origin: iterate-ch/cyberduck

/**
 * @param source Source file or folder
 * @param target Target file or folder
 * @return False if not supported for given files
 */
default boolean isSupported(Path source, Path target) {
  return target.getParent().attributes().getPermission().isWritable();
}

代码示例来源:origin: iterate-ch/cyberduck

private Path inflate(final Session<?> session, final Path file) throws BackgroundException {
  final String fileName = file.getName();
  if(filenameProvider.isDeflated(fileName)) {
    final String filename = filenameProvider.inflate(session, fileName);
    return new Path(file.getParent(), filename, EnumSet.of(Path.Type.file), file.attributes());
  }
  return file;
}

代码示例来源:origin: iterate-ch/cyberduck

/**
 * @param path Filename
 * @return Unarchive command
 */
public String getDecompressCommand(final Path path) {
  return MessageFormat.format(preferences.getProperty(String.format("archive.command.expand.%s", this.getIdentifier())),
      this.escape(path.getAbsolute()), this.escape(path.getParent().getAbsolute()));
}

代码示例来源:origin: iterate-ch/cyberduck

public DescriptiveUrl getRemote() {
  if(this.roots.size() == 1) {
    return new DefaultUrlProvider(host).toUrl(this.getRoot().remote).find(DescriptiveUrl.Type.provider);
  }
  else {
    return new DefaultUrlProvider(host).toUrl(this.getRoot().remote.getParent()).find(DescriptiveUrl.Type.provider);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException {
  if(status.isExists()) {
    new LocalDeleteFeature(session).delete(Collections.singletonList(renamed), new DisabledPasswordCallback(), callback);
  }
  if(!session.toPath(file).toFile().renameTo(session.toPath(renamed).toFile())) {
    throw new LocalExceptionMappingService().map("Cannot rename {0}", new NoSuchFileException(file.getName()), file);
  }
  // Copy attributes from original file
  return new Path(renamed.getParent(), renamed.getName(), renamed.getType(),
    new LocalAttributesFinderFeature(session).find(renamed));
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
  try {
    Files.createDirectory(session.toPath(folder));
  }
  catch(IOException e) {
    throw new LocalExceptionMappingService().map("Cannot create folder {0}", e, folder);
  }
  return new Path(folder.getParent(), folder.getName(), folder.getType(),
    new LocalAttributesFinderFeature(session).find(folder));
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
  try {
    Files.copy(session.toPath(source), session.toPath(target), StandardCopyOption.REPLACE_EXISTING);
    // Copy attributes from original file
    return new Path(target.getParent(), target.getName(), target.getType(),
      new LocalAttributesFinderFeature(session).find(target));
  }
  catch(IOException e) {
    throw new LocalExceptionMappingService().map("Cannot copy {0}", e, source);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public boolean isSupported(final Path file) {
  if(containerService.isContainer(file)) {
    if(PreferencesFactory.get().getBoolean("sds.delete.dataroom.enable")) {
      // Need the query permission on the parent data room if file itself is subroom
      new SDSPermissionsFeature(session, nodeid).containsRole(containerService.getContainer(file.getParent()),
        SDSPermissionsFeature.MANAGE_ROLE);
    }
    return false;
  }
  return new SDSPermissionsFeature(session, nodeid).containsRole(file, SDSPermissionsFeature.DELETE_ROLE);
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
  if(Checksum.NONE == status.getChecksum()) {
    status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status));
  }
  status.setTimestamp(System.currentTimeMillis());
  final StatusOutputStream<BaseB2Response> out = writer.write(file, status, new DisabledConnectionCallback());
  new DefaultStreamCloser().close(out);
  return new Path(file.getParent(), file.getName(), file.getType(),
    new B2AttributesFinderFeature(session, fileid).toAttributes((B2FileResponse) out.getStatus()));
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
  status.setLength(0L);
  final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback());
  new DefaultStreamCloser().close(out);
  final StorageObject metadata = out.getStatus();
  return new Path(file.getParent(), file.getName(), file.getType(),
    new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata));
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
  try {
    final CreateFolderResult result = new DbxUserFilesRequests(session.getClient()).createFolderV2(folder.getAbsolute(), false);
    return new Path(folder.getParent(), folder.getName(), folder.getType(),
      new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata()));
  }
  catch(DbxException e) {
    throw new DropboxExceptionMappingService().map(e);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
  try {
    final IRODSFileSystemAO fs = session.getClient();
    final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(folder.getAbsolute());
    fs.mkdir(f, false);
    return new Path(folder.getParent(), folder.getName(), folder.getType(),
      new IRODSAttributesFinderFeature(session).find(folder));
  }
  catch(JargonException e) {
    throw new IRODSExceptionMappingService().map("Cannot create folder {0}", e, folder);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
  if(Checksum.NONE == status.getChecksum()) {
    status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status));
  }
  new DefaultStreamCloser().close(writer.write(file, status, new DisabledConnectionCallback()));
  return new Path(file.getParent(), file.getName(), file.getType(), new AzureAttributesFinderFeature(session, context).find(file));
}

相关文章