use of ch.cyberduck.core.local.FinderLocal in project cyberduck by iterate-ch.
the class ApplicationSupportDirectoryFinder method find.
@Override
public Local find() {
final NSArray directories = FoundationKitFunctions.library.NSSearchPathForDirectoriesInDomains(FoundationKitFunctions.NSSearchPathDirectory.NSApplicationSupportDirectory, FoundationKitFunctions.NSSearchPathDomainMask.NSUserDomainMask, true);
final String application = preferences.getProperty("application.name");
if (directories.count().intValue() == 0) {
log.error("Failed searching for application support directory");
return new FinderLocal("~/Library/Application Support", application);
} else {
final String directory = directories.objectAtIndex(new NSUInteger(0)).toString();
if (log.isInfoEnabled()) {
log.info(String.format("Found application support directory in %s", directory));
}
final Local folder = new FinderLocal(directory, application);
if (log.isDebugEnabled()) {
log.debug(String.format("Use folder %s for application support directory", folder));
}
return folder;
}
}
use of ch.cyberduck.core.local.FinderLocal in project cyberduck by iterate-ch.
the class BundleApplicationResourcesFinder method bundle.
public NSBundle bundle() {
if (cached != null) {
return cached;
}
if (log.isInfoEnabled()) {
log.info("Loading application bundle resources");
}
final NSBundle main = NSBundle.mainBundle();
if (null == main) {
cached = null;
} else {
final Local executable = new FinderLocal(main.executablePath());
cached = this.bundle(main, executable);
}
return cached;
}
use of ch.cyberduck.core.local.FinderLocal in project cyberduck by iterate-ch.
the class LibraryLogDirectoryFinder method find.
@Override
public Local find() {
final NSArray directories = FoundationKitFunctions.library.NSSearchPathForDirectoriesInDomains(FoundationKitFunctions.NSSearchPathDirectory.NSLibraryDirectory, FoundationKitFunctions.NSSearchPathDomainMask.NSUserDomainMask, true);
final String application = preferences.getProperty("application.name");
if (directories.count().intValue() == 0) {
log.error("Failed searching for library directory");
return new FinderLocal("~/Library/Logs", application);
} else {
final String directory = directories.objectAtIndex(new NSUInteger(0)).toString();
if (log.isInfoEnabled()) {
log.info(String.format("Found library directory in %s", directory));
}
final Local folder = new FinderLocal(new FinderLocal(directory, "Logs"), application);
if (log.isDebugEnabled()) {
log.debug(String.format("Use folder %s for log directory", folder));
}
return folder;
}
}
use of ch.cyberduck.core.local.FinderLocal in project cyberduck by iterate-ch.
the class SecurityApplicationGroupSupportDirectoryFinder method find.
@Override
public Local find() {
final NSFileManager manager = NSFileManager.defaultManager();
if (manager.respondsToSelector(Foundation.selector("containerURLForSecurityApplicationGroupIdentifier:"))) {
final NSURL group = manager.containerURLForSecurityApplicationGroupIdentifier(identifier);
if (null == group) {
log.warn("Missing com.apple.security.application-groups in sandbox entitlements");
} else {
// You should organize the contents of this directory in the same way that any other Library folder is organized
final String application = PreferencesFactory.get().getProperty("application.datafolder.name");
final Local folder = new FinderLocal(String.format("%s/Library/Application Support", group.path()), application);
final Local previous = new ApplicationSupportDirectoryFinder().find();
if (previous.exists() && !previous.isSymbolicLink()) {
log.warn(String.format("Migrate application support folder from %s to %s", previous, folder));
// Rename folder recursively
try {
FileUtils.copyDirectory(new File(previous.getAbsolute()), new File(folder.getAbsolute()));
log.warn(String.format("Move application support folder %s to Trash", previous));
try {
final Trash trash = LocalTrashFactory.get();
trash.trash(previous);
final Symlink symlink = LocalSymlinkFactory.get();
symlink.symlink(previous, folder.getAbsolute());
} catch (AccessDeniedException e) {
log.warn(String.format("Failure cleaning up previous application support directory. %s", e.getMessage()));
}
} catch (IOException e) {
log.warn(String.format("Failure migrating %s to security application group directory %s. %s", previous, folder, e.getMessage()));
}
} else {
log.debug(String.format("No previous application support folder found in %s", previous));
}
return folder;
}
}
log.warn("Missing support for security application groups. Default to application support directory");
// Fallback for 10.7 and earlier
return new ApplicationSupportDirectoryFinder().find();
}
use of ch.cyberduck.core.local.FinderLocal in project cyberduck by iterate-ch.
the class SharedFileListApplicationLoginRegistryTest method testRegister.
@Test
@Ignore
public void testRegister() {
final SharedFileListApplicationLoginRegistry registry = new SharedFileListApplicationLoginRegistry(new LaunchServicesApplicationFinder());
final Application application = new Application("ch.sudo.cyberduck");
assertTrue(registry.register(application));
assertTrue(new FinderSidebarService(SidebarService.List.login).contains(new FinderLocal(NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(application.getIdentifier()))));
assertTrue(registry.unregister(application));
}
Aggregations