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

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

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

Path.isFile介绍

暂无

代码示例

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

@Override
public boolean isSupported(final Path file, final Type type) {
  return file.isFile();
}

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

public SimplePathPredicate(final Path file) {
  this.file = file;
  this.type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory;
  this.path = file.getAbsolute();
}

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

@Override
  protected int compareFirst(final Path p1, final Path p2) {
    if((p1.isDirectory() && p2.isDirectory())
        || p1.isFile() && p2.isFile()) {
      if(ascending) {
        return impl.compare(descriptor.getKind(p1), descriptor.getKind(p2));
      }
      return -impl.compare(descriptor.getKind(p1), descriptor.getKind(p2));
    }
    if(p1.isFile()) {
      return ascending ? 1 : -1;
    }
    return ascending ? -1 : 1;
  }
}

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

@Override
  public int compare(final Path o1, final Path o2) {
    if(o1.isDirectory() && o2.isDirectory()) {
      return 0;
    }
    if(o1.isFile() && o2.isFile()) {
      return 0;
    }
    if(o1.isDirectory()) {
      return -1;
    }
    if(o2.isDirectory()) {
      return 1;
    }
    return 0;
  }
}

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

public CaseInsensitivePathPredicate(final Path file) {
  this.type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory;
  this.path = StringUtils.lowerCase(file.getAbsolute());
}

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

@Override
public Map<String, String> getMetadata(final Path file) throws BackgroundException {
  if(file.isFile() || file.isPlaceholder()) {
    try {
      return new S3AttributesFinderFeature(session).find(file).getMetadata();
    }
    catch(NotfoundException e) {
      if(file.isPlaceholder()) {
        // No placeholder file may exist but we just have a common prefix
        return Collections.emptyMap();
      }
      throw e;
    }
  }
  return Collections.emptyMap();
}

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

@Override
  public void visit(final AttributedList<Path> list, final int index, final Path p) {
    if(p.isFile()) {
      if(p.attributes().isDuplicate()) {
        if(p.attributes().getRevision() == 1) {
          final Map<String, String> custom = new HashMap<>(p.attributes().getCustom());
          custom.put(SpectraVersioningFeature.KEY_REVERTABLE, Boolean.TRUE.toString());
          p.attributes().setCustom(custom);
        }
      }
    }
  }
});

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

/**
 * @param selected File
 * @return True if the selected path is editable (not a directory and no known binary file)
 */
public boolean isEditable(final Path selected) {
  if(this.isMounted()) {
    if(pool.getHost().getCredentials().isAnonymousLogin()) {
      return false;
    }
    return selected.isFile();
  }
  return false;
}

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

@Override
public String getKind(final Path file) {
  if(file.isFile()) {
    return this.getKind(file.getName());
  }
  if(file.isDirectory()) {
    return LocaleFactory.localizedString("Folder");
  }
  return LocaleFactory.localizedString("Unknown");
}

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

private void updateQuickLookSelection(final List<Path> selected) {
  final List<TransferItem> downloads = new ArrayList<TransferItem>();
  for(Path file : selected) {
    if(!file.isFile()) {
      continue;
    }
    downloads.add(new TransferItem(file, TemporaryFileServiceFactory.get().create(pool.getHost().getUuid(), file)));
  }
  if(downloads.size() > 0) {
    final Transfer download = new DownloadTransfer(pool.getHost(), downloads);
    final TransferOptions options = new TransferOptions();
    this.background(new QuicklookTransferBackgroundAction(this, quicklook, pool, download, options, downloads));
  }
}

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

public DefaultPathPredicate(final Path file) {
  final Path.Type type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory;
  String qualifier = StringUtils.EMPTY;
  if(StringUtils.isNotBlank(file.attributes().getRegion())) {
    if(new PathContainerService().isContainer(file)) {
      qualifier += file.attributes().getRegion();
    }
  }
  if(file.isFile()) {
    if(StringUtils.isNotBlank(file.attributes().getVersionId())) {
      qualifier += file.attributes().getVersionId();
    }
  }
  final String path = file.getAbsolute();
  reference = "[" + type + "]" + "-" + qualifier + path;
}

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

/**
   * This creates an URL that uses Cookie-based Authentication. The ACLs for the given Google user account
   * has to be setup first.
   * <p>
   * Google Storage lets you provide browser-based authenticated downloads to users who do not have
   * Google Storage accounts. To do this, you apply Google account-based ACLs to the object and then
   * you provide users with a URL that is scoped to the object.
   */
  @Override
  public DescriptiveUrlBag toUrl(final Path file) {
    final DescriptiveUrlBag list = new DefaultUrlProvider(session.getHost()).toUrl(file);
    if(file.isFile()) {
      // Authenticated browser download using cookie-based Google account authentication in conjunction with ACL
      list.add(new DescriptiveUrl(URI.create(String.format("https://storage.cloud.google.com%s",
          URIEncoder.encode(file.getAbsolute()))), DescriptiveUrl.Type.authenticated,
          MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Authenticated"))));
    }
    return list;
  }
}

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

@Override
  public DescriptiveUrlBag toUrl(final Path file) {
    final DescriptiveUrlBag list = new DescriptiveUrlBag();
    if(file.isFile()) {
      if(file.attributes().getLink() != null) {
        list.add(file.attributes().getLink());
      }
    }
    return list;
  }
}

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

@Override
  public DescriptiveUrlBag toUrl(final Path file) {
    if(file.isVolume()) {
      return DescriptiveUrlBag.empty();
    }
    final DescriptiveUrlBag list = new DescriptiveUrlBag();
    if(file.isFile()) {
      final String download = String.format("%s/file/%s/%s", session.getClient().getDownloadUrl(),
        URIEncoder.encode(containerService.getContainer(file).getName()),
        URIEncoder.encode(containerService.getKey(file)));
      list.add(new DescriptiveUrl(URI.create(download), DescriptiveUrl.Type.http,
        MessageFormat.format(LocaleFactory.localizedString("{0} URL"), Scheme.https.name().toUpperCase(Locale.ROOT))));
    }
    return list;
  }
}

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

/**
 * @param file File or bucket
 * @return Encryption algorithm used for file or null if not encrypted. For buckets, return setting in preferences if any.
 */
@Override
public Algorithm getEncryption(final Path file) throws BackgroundException {
  if(file.isFile() || file.isPlaceholder()) {
    try {
      return new S3AttributesFinderFeature(session).find(file).getEncryption();
    }
    catch(NotfoundException e) {
      if(file.isPlaceholder()) {
        // No placeholder file may exist but we just have a common prefix
        return Algorithm.NONE;
      }
      throw e;
    }
  }
  return Algorithm.NONE;
}

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

@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
  if(file.isFile()) {
    try {
      Files.createFile(session.toPath(file));
    }
    catch(FileAlreadyExistsException e) {
      //
    }
    catch(IOException e) {
      throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file);
    }
  }
  return new Path(file.getParent(), file.getName(), file.getType(),
    new LocalAttributesFinderFeature(session).find(file));
}

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

@Override
public PathAttributes find(final Path file) throws BackgroundException {
  final PathAttributes attributes = new PathAttributes(delegate.withCache(new CryptoPathCache(cache)).find(vault.encrypt(session, file)));
  if(file.isFile()) {
    attributes.setSize(vault.toCleartextSize(attributes.getSize()));
  }
  return attributes;
}

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

@Action
public void insideButtonClicked(final ID sender) {
  final Path selected = this.getSelectedPath(); //first row selected
  if(null == selected) {
    return;
  }
  if(selected.isDirectory()) {
    this.setWorkdir(selected);
  }
  else if(selected.isFile() || this.getSelectionCount() > 1) {
    if(preferences.getBoolean("browser.doubleclick.edit")) {
      this.editButtonClicked(null);
    }
    else {
      this.downloadButtonClicked(null);
    }
  }
}

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

@Override
  public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException {
    final TransferStatus status = super.prepare(file, local, parent, progress);
    if(file.isFile()) {
      if(parent.isExists()) {
        final Write.Append append = upload.append(file, status.getLength(), cache);
        if(append.append && append.size < local.attributes().getSize()) {
          // Append to existing file
          status.setAppend(true);
          status.setLength(status.getLength() - append.size);
          status.setOffset(append.size);
          // Disable use of temporary target when resuming upload
          status.rename((Path) null);
        }
      }
    }
    return status;
  }
}

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

@Override
public DescriptiveUrlBag toUrl(final Path file) {
  final DescriptiveUrlBag list = new DescriptiveUrlBag();
  list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file));
  if(file.isFile()) {
    list.add(this.createSignedUrl(file, 60 * 60));
    // Default signed URL expiring in 24 hours.
    list.add(this.createSignedUrl(file, PreferencesFactory.get().getInteger("s3.url.expire.seconds")));
    // Week
    list.add(this.createSignedUrl(file, 7 * 24 * 60 * 60));
    // Month
    list.add(this.createSignedUrl(file, 7 * 24 * 60 * 60 * 4));
  }
  return list;
}

相关文章