Пример #1
0
 @Override
 protected void invalidate() {
   for (Session s : transfer.getSessions()) {
     s.removeProgressListener(pl);
   }
   transfer.removeListener(tl);
   filesPopup.menu().setDelegate(null);
   super.invalidate();
 }
 protected List<String> getContainers() {
   // List S3 containers
   final Session session =
       SessionFactory.createSession(
           new Host(Protocol.S3_SSL, Protocol.S3_SSL.getDefaultHostname(), host.getCredentials()));
   if (session.getHost().getCredentials().validate(session.getHost().getProtocol())) {
     List<String> buckets = new ArrayList<String>();
     for (Path bucket : session.mount().children()) {
       buckets.add(bucket.getName());
     }
     Collections.sort(buckets);
     return buckets;
   }
   return Collections.emptyList();
 }
Пример #3
0
 /** @return */
 public List<Path> copy() {
   return this.copy(SessionFactory.createSession(session.getHost()));
 }
Пример #4
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);
  }