本文整理了Java中ch.cyberduck.core.Local.exists()
方法的一些代码示例,展示了Local.exists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Local.exists()
方法的具体详情如下:
包路径:ch.cyberduck.core.Local
类名称:Local
方法名:exists
[英]Does not follow symlinks. Can be expensive if called many times due to symlink check.
[中]不遵循符号链接。如果由于符号链接检查而多次调用,可能会很昂贵。
代码示例来源:origin: iterate-ch/cyberduck
/**
* Does not follow symlinks. Can be expensive if called many times due to symlink check.
*
* @return True if the path exists on the file system.
* @see <a href="https://rules.sonarsource.com/java/tag/performance/RSPEC-3725"/>
*/
public boolean exists() {
return this.exists(LinkOption.NOFOLLOW_LINKS);
}
代码示例来源:origin: iterate-ch/cyberduck
/**
* SSH specific
*
* @return true if public key authentication should be used. This is the case, if a
* private key file has been specified
* @see #setIdentity
*/
public boolean isPublicKeyAuthentication() {
if(null == identity) {
return false;
}
return identity.exists();
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public void truncate(final Long length) {
this.length = length;
if(temporary.exists()) {
try {
final RandomAccessFile file = random();
if(length < file.length()) {
// Truncate current
file.setLength(length);
}
}
catch(IOException e) {
log.warn(String.format("Failure truncating file %s to %d", temporary, length));
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException {
if(local.isFile()) {
if(local.exists()) {
if(log.isInfoEnabled()) {
log.info(String.format("Skip file %s", file));
}
return false;
}
}
return super.accept(file, local, parent);
}
}
代码示例来源:origin: iterate-ch/cyberduck
protected OutputStream getOutputStream(final String path, final boolean append) throws LocalAccessDeniedException {
try {
final Set<OpenOption> options = new HashSet<>();
options.add(StandardOpenOption.WRITE);
if(!this.exists()) {
options.add(StandardOpenOption.CREATE);
}
if(append) {
options.add(StandardOpenOption.APPEND);
}
else {
options.add(StandardOpenOption.TRUNCATE_EXISTING);
}
final FileChannel channel = FileChannel.open(Paths.get(path), options);
return Channels.newOutputStream(channel);
}
catch(IOException e) {
throw new LocalAccessDeniedException(e.getMessage(), e);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean exists(final LinkOption... options) {
NSURL resolved = null;
try {
resolved = this.lock(false);
if(null == resolved) {
return super.exists(options);
}
return Files.exists(Paths.get(resolved.path()));
}
catch(AccessDeniedException e) {
return super.exists(options);
}
finally {
this.release(resolved);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public void save(final Host bookmark, final Local directory) {
if(!directory.exists()) {
return;
}
if(log.isInfoEnabled()) {
log.info(String.format("Save default download folder %s for bookmark %s", directory, bookmark));
}
bookmark.setDownloadFolder(directory);
if(collection.contains(bookmark)) {
collection.collectionItemChanged(bookmark);
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public void save(final Host bookmark, final Local directory) {
if(!directory.exists()) {
return;
}
if(log.isInfoEnabled()) {
log.info(String.format("Save default upload folder %s for bookmark %s", directory, bookmark));
}
bookmark.setUploadFolder(directory);
if(collection.contains(bookmark)) {
collection.collectionItemChanged(bookmark);
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException {
if(!local.exists()) {
// Local file is no more here
throw new NotfoundException(local.getAbsolute());
}
return true;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean validate(final Transfer transfer) {
if(transfer.getLocal() != null) {
for(TransferItem l : transfer.getRoots()) {
if(l.local.exists()) {
return true;
}
}
}
return false;
}
});
代码示例来源:origin: iterate-ch/cyberduck
public List<License> open() throws AccessDeniedException {
final List<License> keys = new ArrayList<License>();
if(folder.exists()) {
for(Local key : folder.list().filter(filter)) {
keys.add(this.open(key));
}
}
return keys;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException {
final Local volume = local.getVolume();
if(!volume.exists()) {
throw new NotfoundException(String.format("Volume %s not mounted", volume.getAbsolute()));
}
return true;
}
代码示例来源:origin: iterate-ch/cyberduck
/**
* Register application in launch services database
*
* @param application Bundle identifier
*/
public boolean register(final Local application) {
synchronized(NSWorkspace.class) {
if(!application.exists()) {
return false;
}
return this.register(application.getAbsolute());
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
final ListProgressListener listener) throws BackgroundException {
if(log.isDebugEnabled()) {
log.debug(String.format("Children for %s", directory));
}
final Set<TransferItem> children = new HashSet<TransferItem>();
final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache);
if(finder.find(directory)) {
children.addAll(download.list(session, directory, local, listener));
}
if(local.exists()) {
children.addAll(upload.list(session, directory, local, listener));
}
return new ArrayList<TransferItem>(children);
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Local find(final Host bookmark) {
if(null != bookmark.getUploadFolder()) {
if(bookmark.getUploadFolder().exists()) {
return bookmark.getUploadFolder();
}
}
final Local directory = LocalFactory.get(preferences.getProperty("local.user.home"));
if(log.isInfoEnabled()) {
log.info(String.format("Suggest default upload folder %s for bookmark %s", directory, bookmark));
}
return directory;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean isInstalled(final Application application) {
if(Application.notfound.equals(application)) {
return false;
}
return LocalFactory.get(application.getIdentifier()).exists();
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Local find(final Host bookmark) {
if(null != bookmark.getDownloadFolder()) {
if(bookmark.getDownloadFolder().exists()) {
return bookmark.getDownloadFolder();
}
}
final Local directory = LocalFactory.get(preferences.getProperty("queue.download.folder")).withBookmark(
preferences.getProperty("queue.download.folder.bookmark"));
if(log.isInfoEnabled()) {
log.info(String.format("Suggest default download folder %s for bookmark %s", directory, bookmark));
}
return directory;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean validate(final Transfer transfer) {
if(transfer.getLocal() != null) {
if(!transfer.isComplete()) {
return false;
}
if(!transfer.isRunning()) {
for(TransferItem l : transfer.getRoots()) {
if(l.local.exists()) {
return true;
}
}
}
}
return false;
}
});
代码示例来源:origin: iterate-ch/cyberduck
/**
* @param file A valid bookmark dictionary
* @return Null if the file cannot be deserialized
* @throws AccessDeniedException If the file is not readable
*/
@Override
public S read(final Local file) throws AccessDeniedException {
if(!file.exists()) {
throw new LocalAccessDeniedException(file.getAbsolute());
}
if(!file.isFile()) {
throw new LocalAccessDeniedException(file.getAbsolute());
}
final S deserialized = this.read(file.getInputStream());
if(null == deserialized) {
throw new AccessDeniedException(String.format("Failure parsing file %s", file.getName()));
}
return deserialized;
}
代码示例来源:origin: iterate-ch/cyberduck
/**
* @param file File
* @param size Requested size
* @return Cached icon
*/
@Override
public NSImage fileIcon(final Local file, final Integer size) {
NSImage icon = null;
if(file.exists()) {
icon = this.load(file.getAbsolute(), size);
if(null == icon) {
return this.put(file.getAbsolute(),
this.convert(file.getName(), NSWorkspace.sharedWorkspace().iconForFile(file.getAbsolute()), size), size);
}
}
if(null == icon) {
return this.iconNamed("notfound.tiff", size);
}
return icon;
}
内容来源于网络,如有侵权,请联系作者删除!