buildframework/helium/sf/java/legacy/src/com/nokia/ant/taskdefs/CopyParallelTask.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     3
 * All rights reserved.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     4
 * This component and the accompanying materials are made available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     6
 * which accompanies this distribution, and is available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     8
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     9
 * Initial Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    10
 * Nokia Corporation - initial contribution.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    11
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    12
 * Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    13
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    14
 * Description: 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    15
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    16
 */
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    17
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.ant.taskdefs;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.io.IOException;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import java.util.Enumeration;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    23
import java.util.Vector;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    25
import org.apache.tools.ant.BuildException;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import org.apache.tools.ant.Project;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    27
import org.apache.tools.ant.taskdefs.Copy;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import org.apache.tools.ant.types.FilterSet;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
import org.apache.tools.ant.types.FilterSetCollection;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
/**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    32
 * Copies a file(s) or directory(s) to a new file(s) or directory(s) using parallel threads. Number
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    33
 * of parallel threads can be defined by threadCount. Files are only copied if the source file is
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    34
 * newer than the destination file, or when the destination file does not exist. It is possible to
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    35
 * explicitly overwrite existing files.</p>
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    36
 * 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    37
 * 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
 * @ant.task category="Filesystem"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
 * @since Helium 0.21
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    40
 * 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    41
 */
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    42
public class CopyParallelTask extends Copy {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    static final String LINE_SEPARATOR = System.getProperty("line.separator");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    private int copyThreadCount;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    private int maxThreadCount;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    47
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
     * CopyParallelTask task constructor.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    51
    public CopyParallelTask() {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        setTaskName("copy-parallel");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
     * Perform the copy operation in parallel.
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    57
     * 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
     * @exception BuildException if an error occurs.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    60
    public final void execute() {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    61
        super.execute();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    62
        // wait until all copy threads are dead
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    63
        while (copyThreadCount > 0) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
            try {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
                Thread.sleep(500);
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    66
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    67
            catch (InterruptedException e) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
                if (failonerror) {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    69
                    throw new BuildException("Copy parallel task has been interrupted "
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    70
                        + e.getMessage());
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
                log("Copy parallel task has been interrupted " + e.getMessage(), Project.MSG_ERR);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
            }
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    74
        }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    75
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
     * Set maximum number of thread.
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    80
     * 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
     * @param threadCount maximum number of threads
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    83
    public final void setThreadCount(final int threadCount) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    84
        // Limit max. threads to 8 otherwise we experience freezing when using the fastcopy task on
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    85
        // 8 processor build machines
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    86
        if (threadCount > 8) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    87
            this.maxThreadCount = 8;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    88
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    89
        else {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
            this.maxThreadCount = threadCount;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    94
    /**
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    95
     * Actually does the file (and possibly empty directory) copies. This is a good method for
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    96
     * subclasses to override.
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    98
    protected final void doFileOperations() {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
        Vector filterSets = getFilterSets();
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   100
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        // set default thread count to 1 if it is not set
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   102
        if (maxThreadCount < 1) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   103
            maxThreadCount = 1;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   104
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   105
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   106
        if (fileCopyMap.size() > 0) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   107
            log("Copying " + fileCopyMap.size() + " file" + (fileCopyMap.size() == 1 ? "" : "s")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   108
                + " to " + destDir.getAbsolutePath() + " using " + maxThreadCount
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
                + " threads in parallel.");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   111
            Enumeration fileEnum = fileCopyMap.keys();
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   112
            while (fileEnum.hasMoreElements()) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   113
                String fromFile = (String) fileEnum.nextElement();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
                String[] toFiles = (String[]) fileCopyMap.get(fromFile);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
                for (int i = 0; i < toFiles.length; i++) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
                    String toFile = toFiles[i];
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
                    if (fromFile.equals(toFile)) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
                        log("Skipping self-copy of " + fromFile, verbosity);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
                        continue;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
                    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
                    log("Copying " + fromFile + " to " + toFile, verbosity);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
                    FilterSetCollection executionFilters = new FilterSetCollection();
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   126
                    if (filtering) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
                        executionFilters.addFilterSet(getProject().getGlobalFilterSet());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
                    }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   129
                    for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   130
                        executionFilters.addFilterSet((FilterSet) filterEnum.nextElement());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   131
                    }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   132
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   133
                    while (true) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   134
                        if (copyThreadCount < maxThreadCount) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   135
                            CopyThread copyThread = new CopyThread(fromFile, toFile, executionFilters);
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   136
                            copyThread.start();
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   137
                            copyThreadCount++;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   138
                            break;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   139
                        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
                    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
        if (includeEmpty) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   145
            Enumeration dirEnum = dirCopyMap.elements();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
            int createCount = 0;
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   147
            while (dirEnum.hasMoreElements()) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   148
                String[] dirs = (String[]) dirEnum.nextElement();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
                for (int i = 0; i < dirs.length; i++) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   150
                    File file = new File(dirs[i]);
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   151
                    if (!file.exists()) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   152
                        if (!file.mkdirs()) {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   153
                            log("Unable to create directory " + file.getAbsolutePath(), Project.MSG_ERR);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   154
                        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   155
                        else {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
                            createCount++;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
                        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
                    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
            if (createCount > 0) {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   162
                log("Copied " + dirCopyMap.size() + " empty director"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   163
                    + (dirCopyMap.size() == 1 ? "y" : "ies") + " to " + createCount
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   164
                    + " empty director" + (createCount == 1 ? "y" : "ies") + " under "
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
                    + destDir.getAbsolutePath());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   171
     * private class to start a new thread to copy a single file or or directory.
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   173
    private class CopyThread extends Thread {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
        private String fromFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
        private String toFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
        private FilterSetCollection executionFilters;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        private Vector filterChains;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
        private String inputEncoding;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
        private String outputEncoding;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   180
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   181
        public CopyThread(String fromFile, String toFile, FilterSetCollection executionFilters) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
            this.fromFile = fromFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
            this.toFile = toFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
            this.executionFilters = executionFilters;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
            this.filterChains = getFilterChains();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
            this.inputEncoding = getEncoding();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
            this.outputEncoding = getOutputEncoding();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   190
        public void run() {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
            try {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   192
                fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   193
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   194
            catch (IOException e) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
                log("Problem found in parallel copy " + e.toString(), Project.MSG_ERR);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
            copyThreadCount--;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
}