示例#1
0
 /**
  * Removes a root from the cache.
  *
  * @param root path to be removed
  */
 static synchronized void removeRoot(String root) {
   RootCache cache = RootCache.getInstance();
   if (cache.isRoot(root)) {
     cache.removeRoot(root);
     notifyListeners(FileSystemListener.ROOT_REMOVED, root);
   }
 }
示例#2
0
 /**
  * Adds a root to the cache.
  *
  * @param root path to add to roots
  */
 static synchronized void addRoot(String root) {
   RootCache cache = RootCache.getInstance();
   if (!cache.isRoot(root)) {
     cache.addRoot(root);
     notifyListeners(FileSystemListener.ROOT_ADDED, root);
   }
 }
示例#3
0
  // JAVADOC COMMENT ELIDED
  public static boolean addFileSystemListener(FileSystemListener listener) {
    if (listener == null) {
      throw new NullPointerException();
    }

    checkReadPermission();

    // Create and register file system events listener in MIDP event system
    // (if there is no registered yet)
    if (!isListenerRegistered) {
      // Create root cache object and fill it's internal cache with
      // currently mounted roots.
      // Cache is used to determine which roots were mounted/unmounted
      // if EventTypes.FC_DISKS_CHANGED_EVENT event arrives.
      RootCache.initialize();

      FileSystemEventHandler.setListener(new FileSystemEventHandler());
      isListenerRegistered = true;
    }

    fileSystemListeners.addElement(listener);

    return true;
  }