예제 #1
0
  @Override
  protected void jobCompleted() {
    super.jobCompleted();

    // If the source files are located inside an archive, optimize the archive file
    AbstractArchiveFile sourceArchiveFile =
        getBaseSourceFolder() == null ? null : getBaseSourceFolder().getParentArchive();
    if (sourceArchiveFile != null
        && sourceArchiveFile.isArchive()
        && sourceArchiveFile.isWritable())
      optimizeArchive((AbstractRWArchiveFile) sourceArchiveFile);

    // If the destination files are located inside an archive, optimize the archive file, only if
    // the destination
    // archive is different from the source one
    AbstractArchiveFile destArchiveFile = baseDestFolder.getParentArchive();
    if (destArchiveFile != null
        && destArchiveFile.isArchive()
        && destArchiveFile.isWritable()
        && !(sourceArchiveFile != null && destArchiveFile.equalsCanonical(sourceArchiveFile)))
      optimizeArchive((AbstractRWArchiveFile) destArchiveFile);

    // If this job corresponds to a file renaming in the same directory, select the renamed file
    // in the active table after this job has finished (and hasn't been cancelled)
    if (files.size() == 1
        && newName != null
        && baseDestFolder.equalsCanonical(files.elementAt(0).getParent())) {
      // Resolve new file instance now that it exists: some remote files do not immediately update
      // file attributes
      // after creation, we need to get an instance that reflects the newly created file attributes
      selectFileWhenFinished(FileFactory.getFile(baseDestFolder.getAbsolutePath(true) + newName));
    }
  }
예제 #2
0
  @Override
  public AbstractFile getRoot() {
    FileURL rootURL = (FileURL) getURL().clone();
    String rootPath = getRootPath();
    rootURL.setPath("/" + vmIdentifier + "/" + rootPath);

    return FileFactory.getFile(rootURL);
  }
예제 #3
0
  public Vector<String> getPossibleCompletions(String path) {
    Vector<String> result = new Vector<String>();
    int index = Math.max(path.lastIndexOf('\\'), path.lastIndexOf('/'));
    if (index != -1) {
      String currentDirectoryName = path.substring(0, index + 1);

      AbstractFile currentDirectory = FileFactory.getFile(currentDirectoryName);
      if (currentDirectory != null && currentDirectory.exists()) {
        long currentDirectoryDate = currentDirectory.getDate();
        if (cachedDirectoryName == null
            || !cachedDirectoryName.equals(currentDirectoryName)
            || currentDirectoryDate != cachedDirectoryDate) {
          AbstractFile[] currentDirectoryFiles;
          try {
            currentDirectoryFiles = getFiles(currentDirectory);
          } catch (IOException e) {
            LOGGER.debug("Caught exception", e);
            return new Vector<String>();
          }

          int nbCurrentDirectoryFiles = currentDirectoryFiles.length;
          cachedDirectoryFileNames = new String[nbCurrentDirectoryFiles];

          for (int i = 0; i < nbCurrentDirectoryFiles; i++) {
            AbstractFile abstractFileI = currentDirectoryFiles[i];
            cachedDirectoryFileNames[i] =
                abstractFileI.getName()
                    + (abstractFileI.isDirectory() ? abstractFileI.getSeparator() : "");
          }

          Arrays.sort(cachedDirectoryFileNames, String.CASE_INSENSITIVE_ORDER);

          cachedDirectoryName =
              currentDirectory.getAbsolutePath()
                  + (currentDirectory.isDirectory() ? "" : currentDirectory.getSeparator());
          cachedDirectoryDate = currentDirectoryDate;
        }

        final String prefix =
            index == path.length() - 1 ? null : path.substring(index + 1).toLowerCase();
        result = PrefixFilter.createPrefixFilter(prefix).filter(cachedDirectoryFileNames);
      }
    }
    return result;
  }
예제 #4
0
  @Override
  protected void jobCompleted() {
    super.jobCompleted();

    // If the destination files are located inside an archive, optimize the archive file
    AbstractArchiveFile archiveFile = baseDestFolder.getParentArchive();
    if (archiveFile != null && archiveFile.isArchive() && archiveFile.isWritable())
      optimizeArchive((AbstractRWArchiveFile) archiveFile);

    // If this job correponds to a 'local copy' of a single file and in the same directory,
    // select the copied file in the active table after this job has finished (and hasn't been
    // cancelled)
    if (files.size() == 1
        && newName != null
        && baseDestFolder.equalsCanonical(files.elementAt(0).getParent())) {
      // Resolve new file instance now that it exists: some remote files do not immediately update
      // file attributes
      // after creation, we need to get an instance that reflects the newly created file attributes
      selectFileWhenFinished(FileFactory.getFile(baseDestFolder.getAbsolutePath(true) + newName));
    }
  }