use of ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder in project cyberduck by iterate-ch.
the class FileManagerTrashFeatureTest method testTrashNonEmpty.
@Test
public void testTrashNonEmpty() throws Exception {
final Trash trash = new FileManagerTrashFeature();
final SupportDirectoryFinder finder = new TemporarySupportDirectoryFinder();
final Local temp = finder.find();
final Local directory = LocalFactory.get(temp, UUID.randomUUID().toString());
directory.mkdir();
final Local sub = LocalFactory.get(directory, UUID.randomUUID().toString());
sub.mkdir();
final Local file = LocalFactory.get(sub, UUID.randomUUID().toString());
final Touch touch = LocalTouchFactory.get();
touch.touch(file);
trash.trash(directory);
}
use of ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder in project cyberduck by iterate-ch.
the class FileManagerTrashFeatureTest method testTrashOpenFile.
@Test
public void testTrashOpenFile() throws Exception {
final Trash trash = new FileManagerTrashFeature();
final SupportDirectoryFinder finder = new TemporarySupportDirectoryFinder();
final Local temp = finder.find();
final Local directory = LocalFactory.get(temp, UUID.randomUUID().toString());
directory.mkdir();
final Local sub = LocalFactory.get(directory, UUID.randomUUID().toString());
sub.mkdir();
final Local file = LocalFactory.get(sub, UUID.randomUUID().toString());
final Touch touch = LocalTouchFactory.get();
touch.touch(file);
try (final OutputStream stream = file.getOutputStream(false)) {
trash.trash(directory);
}
}
use of ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder in project cyberduck by iterate-ch.
the class WorkspaceTrashFeatureTest method testTrashNonEmpty.
@Test
public void testTrashNonEmpty() throws Exception {
final Trash trash = new WorkspaceTrashFeature();
final SupportDirectoryFinder finder = new TemporarySupportDirectoryFinder();
final Local temp = finder.find();
final Local directory = LocalFactory.get(temp, UUID.randomUUID().toString());
directory.mkdir();
final Local sub = LocalFactory.get(directory, UUID.randomUUID().toString());
sub.mkdir();
final Local file = LocalFactory.get(sub, UUID.randomUUID().toString());
final Touch touch = LocalTouchFactory.get();
touch.touch(file);
trash.trash(directory);
}
use of ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder in project cyberduck by iterate-ch.
the class WorkspaceTrashFeatureTest method testTrashOpenFile.
@Test
public void testTrashOpenFile() throws Exception {
final Trash trash = new WorkspaceTrashFeature();
final SupportDirectoryFinder finder = new TemporarySupportDirectoryFinder();
final Local temp = finder.find();
final Local directory = LocalFactory.get(temp, UUID.randomUUID().toString());
directory.mkdir();
final Local sub = LocalFactory.get(directory, UUID.randomUUID().toString());
sub.mkdir();
final Local file = LocalFactory.get(sub, UUID.randomUUID().toString());
final Touch touch = LocalTouchFactory.get();
touch.touch(file);
try (final OutputStream stream = file.getOutputStream(false)) {
trash.trash(directory);
}
}
use of ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder in project cyberduck by iterate-ch.
the class BrowserTableDataSource method namesOfPromisedFilesDroppedAtDestination.
/**
* @return the names (not full paths) of the files that the receiver promises to create at dropDestination. This
* method is invoked when the drop has been accepted by the destination and the destination, in the case of another
* Cocoa application, invokes the NSDraggingInfo method namesOfPromisedFilesDroppedAtDestination. For long
* operations, you can cache dropDestination and defer the creation of the files until the finishedDraggingImage
* method to avoid blocking the destination application.
*/
@Override
public NSArray namesOfPromisedFilesDroppedAtDestination(final NSURL url) {
if (log.isDebugEnabled()) {
log.debug(String.format("Return names of promised files dropped at %s", url));
}
NSMutableArray promisedDragNames = NSMutableArray.array();
if (null != url) {
final Local destination = LocalFactory.get(url.path());
final DownloadFilterOptions options = new DownloadFilterOptions(controller.getSession().getHost());
if (destination.isChild(new TemporarySupportDirectoryFinder().find())) {
options.icon = false;
options.segments = false;
}
final PathPasteboard pasteboard = controller.getPasteboard();
final List<TransferItem> downloads = new ArrayList<TransferItem>();
for (Path p : pasteboard) {
downloads.add(new TransferItem(p, LocalFactory.get(destination, p.getName())));
// Add to returned path names
promisedDragNames.addObject(p.getName());
}
if (downloads.size() == 1) {
if (downloads.iterator().next().remote.isFile()) {
final Local file = downloads.iterator().next().local;
if (!file.exists()) {
try {
LocalTouchFactory.get().touch(file);
if (options.icon) {
IconServiceFactory.get().set(file, new TransferStatus().withLength(0L));
}
} catch (AccessDeniedException e) {
log.warn(String.format("Failure creating file %s %s", file, e.getMessage()));
}
}
}
if (downloads.iterator().next().remote.isDirectory()) {
final Local file = downloads.iterator().next().local;
if (!file.exists()) {
try {
new DefaultLocalDirectoryFeature().mkdir(file);
} catch (AccessDeniedException e) {
log.warn(e.getMessage());
}
}
}
}
// kTemporaryFolderType
final boolean dock = destination.equals(LocalFactory.get("~/Library/Caches/TemporaryItems"));
if (dock) {
for (Path p : pasteboard) {
// Drag to application icon in dock.
controller.edit(p);
}
} else {
final Transfer transfer = new DownloadTransfer(controller.getSession().getHost(), downloads).withOptions(options);
controller.transfer(transfer, Collections.emptyList());
}
pasteboard.clear();
}
// Filenames
return promisedDragNames;
}
Aggregations