Ejemplo n.º 1
0
 /**
  * @param item File
  * @param size Requested size
  * @return Cached icon
  */
 public NSImage iconForPath(final Local item, final Integer size) {
   NSImage icon = null;
   if (item.exists()) {
     icon = this.load(item.getAbsolute(), size);
     if (null == icon) {
       icon = NSWorkspace.sharedWorkspace().iconForFile(item.getAbsolute());
       this.put(item.getAbsolute(), this.convert(icon, size), size);
     }
   }
   if (null == icon) {
     return this.iconForName("notfound.tiff", size);
   }
   return icon;
 }
Ejemplo n.º 2
0
 private void addDownloadPath(Selector action, Local f) {
   if (downloadPathPopup.menu().itemWithTitle(f.getDisplayName()) == null) {
     downloadPathPopup
         .menu()
         .addItemWithTitle_action_keyEquivalent(f.getDisplayName(), action, StringUtils.EMPTY);
     downloadPathPopup.lastItem().setTarget(this.id());
     downloadPathPopup.lastItem().setImage(IconCache.instance().iconForPath(f, 16));
     downloadPathPopup.lastItem().setRepresentedObject(f.getAbsolute());
     if (host.getDownloadFolder().equals(f)) {
       downloadPathPopup.selectItem(downloadPathPopup.lastItem());
     }
   }
 }
Ejemplo n.º 3
0
  @Override
  public void mount(Session s) {
    if (!this.isAvailable()) {
      this.invoke(
          new DefaultMainAction() {
            @Override
            public void run() {}
          });
      return;
    }
    session = s;
    filesystem = GMUserFileSystem.create((fileystemCallback = new FSCallback()).id(), true);

    NSNotificationCenter center = NSNotificationCenter.defaultCenter();
    center.addObserver(
        fileystemCallback.id(),
        Foundation.selector("mountFailed:"),
        GMUserFileSystem.kGMUserFileSystemMountFailed,
        null);
    center.addObserver(
        fileystemCallback.id(),
        Foundation.selector("didMount:"),
        GMUserFileSystem.kGMUserFileSystemDidMount,
        null);
    center.addObserver(
        fileystemCallback.id(),
        Foundation.selector("didUnmount:"),
        GMUserFileSystem.kGMUserFileSystemDidUnmount,
        null);

    final NSMutableArray options = NSMutableArray.array();
    options.addObject(
        "volicon="
            + NSBundle.mainBundle()
                .pathForResource_ofType(session.getHost().getProtocol().disk(), "icns"));
    // You can use the volname option to specify a name for the MacFUSE volume being mounted. This
    // is the name that would show up on the Desktop. In the absence of this option, MacFUSE will
    // automatically generate a name that would incorporate the MacFUSE device index and the
    // user-space file system being used. For example, an SSHFS mount might have an automatically
    // assigned name "MacFUSE Volume 0 (sshfs)".
    final String volume = session.getHost().getHostname();
    options.addObject("volname=" + volume);
    // By default, if MacFUSE detects a change in a file's size during getattr(), it will purge
    // that file's buffer cache. When auto_cache is enabled, MacFUSE will additionally
    // detect modification time changes during getattr() and open() and will automatically
    // purge the buffer cache and/or attributes of the file if necessary. It will also
    // generate the relevant kqueue messages. All this is subject to the attribute timeout.
    // That is, up to one purge can occur per attribute timeout window. As long as the
    // user-space file system's getattr() callback returns up-to-date size and modification
    // time information, this should work as intended. For user-space file systems that wish
    // the kernel to keep up with "remote" changes, this should obviate the need for explicit
    // purging. auto_cache is not enabled by default: it's opt-in.
    options.addObject("auto_cache");
    // This option makes MacFUSE deny all types of access to extended attributes that begin with the
    // "com.apple." prefix. On Mac OS X 10.5.x, this is the preferred option if you wish to disallow
    // entities such as resource forks and Finder information.
    options.addObject("noapplexattr");
    // This option makes MacFUSE deny all types of access to Apple Double (._) files and .DS_Store
    // files. Any existing files will become apparently non-existent. New files that match the
    // criteria will be disallowed from being created.
    options.addObject("noappledouble");
    mountpoint = LocalFactory.createLocal("/Volumes/" + volume);
    if (mountpoint.exists()) {
      // Make sure we do not mount to a already existing path
      final String parent = mountpoint.getParent().getAbsolute();
      int no = 0;
      while (mountpoint.exists()) {
        no++;
        String proposal = volume + "-" + no;
        mountpoint = LocalFactory.createLocal(parent, proposal);
      }
    }
    filesystem.mountAtPath_withOptions_shouldForeground_detachNewThread(
        mountpoint.getAbsolute(), options, true, true);
  }