Package entagged.tageditor.tools.renaming.data

Examples of entagged.tageditor.tools.renaming.data.DirectoryDescriptor


      } else {
        descriptor.setTargetName(fileName);
      }

      // Now create the DirectoryDescritor for the target
      DirectoryDescriptor targetDirectory = assertDirectory(path
          .toString(), true);
      descriptor.setTargetDirectory(targetDirectory);
      targetDirectory.addChild(descriptor);

    } catch (MissingValueException e) {
      descriptor.setMissingFields(e.getMissingFields());
    }
  }
View Full Code Here


    if (target
        && (!FileSystemUtil.isFilesystemCaseSensitive() || renameConfig
            .isSearchSimiliarDirectoriesEnabled())) {
      searchPath = searchPath.toUpperCase();
    }
    DirectoryDescriptor result = (DirectoryDescriptor) path2file
        .get(searchPath);
    if (result != null) {
      /*
       * If the current directory is not marked as target, but now is
       * requested as a target, it must be set as one.
       */
      if (target && !result.isTargetDirectory()) {
        result.setTargetDirectory(true);
        /*
         * This will result in a upward recursion, marking all parent
         * directories as used for target. Stop if no parent file exist.
         */
        DirectoryDescriptor current = result.getParent();
        while (current != null) {
          current.setTargetDirectory(true);
          current = current.getParent();
        }
      }
      // same with source
      if (!target && !result.isSourceDirectory()) {
        result.setSourceDirectory(true);
        DirectoryDescriptor current = result.getParent();
        while (current != null) {
          current.setSourceDirectory(true);
          current = current.getParent();
        }
      }
      return result;
    }
    // From here on, the directory does not exist (In memory).
    File directoryInstance = null;
    if (target)
      directoryInstance = getDirectoryFile(path);
    else
      directoryInstance = new File(path);
    // assert parent directory first.
    // Does a parent exist?
    if (directoryInstance.getParentFile() != null) {
      DirectoryDescriptor parent = assertDirectory(directoryInstance
          .getParent(), target);
      result = new DirectoryDescriptor(directoryInstance.getName(),
          parent, !target, target);
      parent.addChild(result);
    } else {
      // consider, for whatever reason the getName() for a drive (C:\)
      // returns an empty string.
      String rootName = directoryInstance.getAbsolutePath();
      if (rootName.endsWith(File.separator)) {
        rootName = rootName.substring(0, rootName.length() - 1);
      }
      result = new DirectoryDescriptor(rootName, null, !target, target);
      // No, so it is a filesystem root (eg. c:\ or /)
      if (!filesysroots.containsKey(rootName)) {
        filesysroots.put(rootName, result);
      }
    }
View Full Code Here

   * @throws Exception
   *             If {@link #assertDirectory(String, boolean)} throwed one.
   */
  private FileDescriptor insertSourceFile(File audioFile, int bitrate)
      throws Exception {
    DirectoryDescriptor parent = assertDirectory(audioFile.getParent(),
        false);
    FileDescriptor result = new FileDescriptor(audioFile.getName(), parent,
        bitrate);
    parent.addChild(result);
    return result;
  }
View Full Code Here

    if (file.isDirectory()) {
      AbstractFile[] children = file.getChildren();
      for (int i = 0; i < children.length; i++) {
        if (children[i] instanceof DirectoryDescriptor) {
          DirectoryDescriptor dir = (DirectoryDescriptor) children[i];
          if (this.filter.accept(dir)) {
            String path = dir.getPath();
            // has this directory already been accepted after
            // last change of options
            if (acceptedPaths.contains(path)) {
              result.add(dir);
            } else if (!rejectedPaths.contains(path)) {
View Full Code Here

            }
          }

        }
      } else {
        DirectoryDescriptor dir = (DirectoryDescriptor) files[i];
        // Only targetdirectories will be processed. The rest woul just
        // be useless work
        if (dir.isTargetDirectory()) {
          long[] result = processBitrate(dir.getChildren(),
              copyUnmoveable);
          sum += result[0];
          count += result[1];
          if (dir.getOriginalName().indexOf(
              DirectoryPattern.INTERNAL_BITRATE_PATTERN) != -1) {
            /*
             * And now replace the bitrate-Pattern
             */
            long avg = 0;
            if (count > 0) {
              avg = sum / count;
            }
            String newName = dir.getOriginalName().replaceAll(
                DirectoryPattern.INTERNAL_BITRATE_PATTERN,
                String.valueOf(avg));
            dir.overrideName(newName);
          }
        }
      }

    }
View Full Code Here

    if (descriptor.getStatistic().getProperty(
        NoChangeProperty.PROPERTY_NAME) > 0) {
      // The file doesn't need to be renamed.
      return;
    }
    DirectoryDescriptor targetDir = descriptor.getTargetDirectory();
    if (targetDir != null) {
      File targetDirFile = new File(targetDir.getPath());
      if (!targetDirFile.exists()) {
        if (!targetDirFile.mkdirs()) {
          throw new RuntimeException("Can't create "
              + targetDir.getPath());
        }
      }
      /*
       * Now check one more time if the target exists.
       */
 
View Full Code Here

TOP

Related Classes of entagged.tageditor.tools.renaming.data.DirectoryDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.