本文整理了Java中ch.cyberduck.core.Path
类的一些代码示例,展示了Path
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path
类的具体详情如下:
包路径:ch.cyberduck.core.Path
类名称:Path
暂无
代码示例来源: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
public CryptoVault(final Path home, final String masterkey, final byte[] pepper) {
this.home = home;
this.masterkey = new Path(home, masterkey, EnumSet.of(Path.Type.file, Path.Type.vault));
this.pepper = pepper;
// New vault home with vault flag set for internal use
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(home.getType());
type.add(Path.Type.vault);
final Path vault = new Path(home.getAbsolute(), type, new PathAttributes(home.attributes()));
this.filenameProvider = new CryptoFilenameProvider(vault);
this.directoryProvider = new CryptoDirectoryProvider(vault, this);
}
代码示例来源:origin: iterate-ch/cyberduck
public String encode(final Path file) {
final String encoded = URIEncoder.encode(file.getAbsolute());
if(file.isDirectory()) {
if(file.isRoot()) {
return encoded;
}
return String.format("%s/", encoded);
}
return encoded;
}
}
代码示例来源:origin: iterate-ch/cyberduck
public boolean isContainer(final Path file) {
if(file.isRoot()) {
return false;
}
return file.getParent().isRoot();
}
代码示例来源: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
private boolean findTarget(final Path target, final Path root) {
return target.equals(root) || target.isChild(root);
}
}
代码示例来源:origin: iterate-ch/cyberduck
private Path buildNormalizedHomePath(final String rawHomePath) {
final String defaultPath = StringUtils.defaultIfBlank(rawHomePath, Path.HOME);
final String accountRootRegex = String.format("^/?(%s|~~?)/?", accountRoot.getAbsolute());
final String subdirectoryRawPath = defaultPath.replaceFirst(accountRootRegex, "");
if(StringUtils.isEmpty(subdirectoryRawPath)) {
return accountRoot;
}
final String[] subdirectoryPathSegments = StringUtils.split(subdirectoryRawPath, Path.DELIMITER);
Path homePath = accountRoot;
for(final String pathSegment : subdirectoryPathSegments) {
EnumSet<Path.Type> types = EnumSet.of(Path.Type.directory);
if(homePath.getParent().equals(accountRoot)
&& StringUtils.equalsAny(pathSegment, HOME_PATH_PRIVATE, HOME_PATH_PUBLIC)) {
types.add(Path.Type.volume);
}
homePath = new Path(homePath, pathSegment, types);
}
return homePath;
}
代码示例来源: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
protected Path expand(final Path remote, final String format) {
if(remote.getAbsolute().startsWith(format)) {
return new Path(StringUtils.replaceOnce(remote.getAbsolute(), format, workdir.getAbsolute()),
remote.getType());
}
return remote;
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Permission getUnixPermission(final Path file) throws BackgroundException {
try {
return new FTPAttributesFinderFeature(session).find(file).getPermission();
}
catch(InteroperabilityException e) {
for(Path f : session.getFeature(ListService.class).list(file.getParent(), new DisabledListProgressListener())) {
if(f.equals(file)) {
return f.attributes().getPermission();
}
}
}
throw new NotfoundException(file.getAbsolute());
}
代码示例来源: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
@Override
public Path getContainer(final Path file) {
if(file.isRoot()) {
return file;
}
Path previous = file;
Path parent = file.getParent();
while(!parent.isRoot()) {
if(SharepointListService.DEFAULT_NAME.equals(parent.getParent())) {
return parent;
}
else if(SharepointListService.GROUPS_NAME.equals(parent.getParent())) {
return previous;
}
previous = parent;
parent = parent.getParent();
}
return file;
}
}
代码示例来源: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 List<Path> findObjectsAsPaths(final Path workdir, final Predicate<MantaObject> searchPredicate) {
return session.getClient().find(workdir.getAbsolute(), searchPredicate)
.map(adapter::toPath)
.collect(Collectors.toList());
}
代码示例来源:origin: iterate-ch/cyberduck
protected void write(final Session<?> session, final Redundancy feature, final Path file) throws BackgroundException {
if(this.isCanceled()) {
throw new ConnectionCanceledException();
}
if(!level.equals(file.attributes().getStorageClass())) {
listener.message(MessageFormat.format(LocaleFactory.localizedString("Writing metadata of {0}", "Status"),
file.getName()));
feature.setClass(file, level);
}
if(file.isDirectory()) {
if(callback.recurse(file, level)) {
for(Path child : session.getFeature(ListService.class).list(file, new WorkerListProgressListener(this, listener))) {
this.write(session, feature, child);
}
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String getKey(final Path file) {
final String key = super.getKey(file);
if(!file.isRoot() && !this.isContainer(file) && file.isDirectory()) {
return key.concat(String.valueOf(Path.DELIMITER));
}
return key;
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public DescriptiveUrlBag toUrl(final Path file) {
final String nodeid = file.isDirectory() ? file.attributes().getVersionId() : file.getParent().attributes().getVersionId();
if(StringUtils.isBlank(nodeid)) {
return DescriptiveUrlBag.empty();
}
return new DescriptiveUrlBag(Collections.singletonList(
new DescriptiveUrl(URI.create(String.format("%s/#/node/%s",
new HostUrlProvider().withUsername(false).get(session.getHost()), URIEncoder.encode(
nodeid
))),
DescriptiveUrl.Type.http,
MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().toString().toUpperCase(Locale.ROOT)))
));
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Action
public void pathPopupSelectionChanged(final NSPopUpButton sender) {
final String selected = sender.selectedItem().representedObject();
if(selected != null) {
final Path workdir = this.workdir();
Path p = workdir;
while(!p.getAbsolute().equals(selected)) {
p = p.getParent();
}
this.setWorkdir(p);
if(workdir.getParent().equals(p)) {
this.setWorkdir(p, workdir);
}
else {
this.setWorkdir(p);
}
}
}
代码示例来源: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 Path resolve(final String filename) {
// Intermediate directory
final Path first = new Path(metadataRoot, filename.substring(0, 2), metadataRoot.getType());
// Intermediate directory
final Path second = new Path(first, filename.substring(2, 4), metadataRoot.getType());
return new Path(second, filename, EnumSet.of(Path.Type.file, Path.Type.encrypted, Path.Type.vault));
}
内容来源于网络,如有侵权,请联系作者删除!