|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: File operation for copying the installable files |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.tools.themeinstaller.defrep.operations; |
|
20 |
|
21 import java.io.File; |
|
22 import java.io.FileNotFoundException; |
|
23 import java.io.IOException; |
|
24 |
|
25 /** |
|
26 * Operation for copying files. |
|
27 */ |
|
28 public class CopyOperation extends FileOperation |
|
29 { |
|
30 |
|
31 // Destination file |
|
32 private File iDestination; |
|
33 |
|
34 // Append flag |
|
35 private boolean iAppend; |
|
36 |
|
37 /** |
|
38 * Create a copy operation |
|
39 * |
|
40 * @param aSource Source file name |
|
41 * @param aDestination Destination file name |
|
42 * @param aAppend Append to the destination file if it exists |
|
43 */ |
|
44 public CopyOperation( File aSource, File aDestination, boolean aAppend ) |
|
45 { |
|
46 iFile = aSource; |
|
47 iDestination = aDestination; |
|
48 iAppend = aAppend; |
|
49 } |
|
50 |
|
51 /* (non-Javadoc) |
|
52 * @see java.lang.Runnable#run() |
|
53 */ |
|
54 public void run() |
|
55 { |
|
56 int error = FileOperationEvent.UNKNOWN_ERROR; |
|
57 |
|
58 // Perform the copy operation |
|
59 try |
|
60 { |
|
61 FileOperationUtils.copyFile( iFile, iDestination, iAppend ); |
|
62 error = FileOperationEvent.OPERATION_SUCCESSFUL; |
|
63 } |
|
64 catch( FileNotFoundException fnfe ) |
|
65 { |
|
66 error = FileOperationEvent.FILE_NOT_FOUND_ERROR; |
|
67 } |
|
68 catch( IOException ioe ) |
|
69 { |
|
70 error = FileOperationEvent.IO_ERROR; |
|
71 } |
|
72 |
|
73 // Report results to the operation listeners |
|
74 super.finished( iDestination, error ); |
|
75 } |
|
76 |
|
77 } |