Changeset 7525


Ignore:
Timestamp:
2004-06-02T10:08:31+12:00 (20 years ago)
Author:
kjdon
Message:

added a method to coppy the contents of a directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r7491 r7525  
    640640    queue.clear();
    641641    }
    642 
     642   
     643    /** Copy the contents from the source directory to the destination
     644     * directory.
     645     * @param source The source directory
     646     * @param destination The destination directory
     647     * @param progress A progress bar to monitor copying progress
     648     * @see org.greenstone.gatherer.Gatherer
     649     */
     650    public void copyDirectoryContents(File source, File destination, LongProgressBar progress)
     651    throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException, WriteNotPermittedException
     652    {
     653    if (!source.isDirectory()) return;
     654    // check that dest dirs exist
     655    destination.mkdirs();
     656   
     657    File [] src_files = source.listFiles();
     658    if (src_files.length == 0) return; // nothing to copy
     659    for (int i=0; i<src_files.length; i++) {
     660        File f = src_files[i];
     661        String f_name = f.getName();
     662        File new_file = new File(destination, f_name);
     663        if (f.isDirectory()) {
     664        copyDirectoryContents(f, new_file, progress);
     665        } else if (f.isFile()) {
     666        copyFile(f, new_file, progress);
     667        }
     668    }
     669   
     670    }
     671   
    643672    /** Copy a file from the source location to the destination location.
    644673     * @param source The source File.
Note: See TracChangeset for help on using the changeset viewer.