public synchronized void scanLibrary() {
   if (scanner == null) {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   } else if (scanner.isAlive()) {
     LOGGER.info("Scanner is already running !");
   } else {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   }
 }
Example #2
0
  // XXX dir.canWrite() has issues on Windows, so verify it directly:
  // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6203387
  public static boolean isDirectoryWritable(File dir) {
    boolean isWritable = false;

    if (dir != null) {
      // new File("").isDirectory() is false, even though getAbsolutePath() returns the right path.
      // this resolves it
      dir = dir.getAbsoluteFile();

      if (dir.isDirectory()) {
        File file =
            new File(
                dir,
                String.format(
                    "pms_directory_write_test_%d_%d.tmp",
                    System.currentTimeMillis(), Thread.currentThread().getId()));

        try {
          if (file.createNewFile()) {
            if (isFileWritable(file)) {
              isWritable = true;
            }

            if (!file.delete()) {
              LOGGER.warn("Can't delete temporary test file: {}", file.getAbsolutePath());
            }
          }
        } catch (IOException | SecurityException ioe) {
        }
      }
    }

    return isWritable;
  }
 public void scanLibrary() {
   if (isScanLibraryRunning()) {
     LOGGER.info(Messages.getString("NetworkTab.70"));
   } else {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   }
 }
 public boolean isScanLibraryRunning() {
   return scanner != null && scanner.isAlive();
 }
 /**
  * Retrieves recursively all the classes belonging to a package.
  *
  * @param packageName
  * @return the list of Class found
  * @throws ClassNotFoundException if any error occurs
  */
 public static List<Class<?>> getClassesInPackage(String packageName)
     throws ClassNotFoundException {
   return getClassesInPackage(packageName, Thread.currentThread().getContextClassLoader());
 }
 public synchronized void stopScanLibrary() {
   if (scanner != null && scanner.isAlive()) {
     PMS.get().getRootFolder(null).stopScan();
   }
 }