Beispiel #1
0
 private void to_directory(Vector sources, File destination_directory)
     throws IOException, InterruptedException {
   Assertion.check(destination_directory.exists());
   for (Enumeration source_scan = sources.elements(); source_scan.hasMoreElements(); ) {
     File source = (File) source_scan.nextElement();
     if (source.isFile()) {
       File destination = File.create(destination_directory.getPath(), source.getName());
       file_to_file(source, destination);
     } else if (_recursive) {
       String source_base = source.getParent();
       if (source_base == null) source_base = ".";
       String destination_base = destination_directory.getCanonicalPath();
       directory_to_directory(source_base, destination_base, source.getName());
     }
   }
 }
Beispiel #2
0
  private void copy_files() throws IOException, InterruptedException {
    File destination = File.create(_destination_name);
    boolean destination_exists = destination.exists();
    boolean destination_is_file = destination_exists && destination.isFile();

    if (destination_is_file || !destination_exists) {
      // Source should be a single file.
      int n_sources = _sources.size();
      boolean ok = n_sources == 1;
      if (ok) {
        File source = (File) _sources.firstElement();
        if (source.isFile()) file_to_file(source, destination);
        else ok = false;
      }
      if (!ok)
        throw new NakshException(
            "If the destination is a file or does "
                + "not exist, then the source must be "
                + "a single file.");
    } else to_directory(_sources, destination);
  }