| 34 |
34 |
import java.io.IOException;
|
| 35 |
35 |
import java.nio.MappedByteBuffer;
|
| 36 |
36 |
import java.nio.channels.FileChannel;
|
|
37 |
import java.nio.file.Files;
|
|
38 |
import java.nio.file.Path;
|
| 37 |
39 |
|
| 38 |
40 |
import org.txm.utils.messages.UtilsCoreMessages;
|
| 39 |
41 |
|
| ... | ... | |
| 61 |
63 |
* copy one file with nio package to accelerate the copy
|
| 62 |
64 |
*
|
| 63 |
65 |
* !!! on windows : max size = 64mo !!!.
|
|
66 |
*
|
|
67 |
* resolve symbolic links
|
| 64 |
68 |
*
|
| 65 |
69 |
* @param source the source
|
| 66 |
70 |
* @param dest the dest
|
| ... | ... | |
| 128 |
132 |
|
| 129 |
133 |
/**
|
| 130 |
134 |
* Copy files. Don't erase the destination directory and replace files if they already exists
|
|
135 |
*
|
|
136 |
* warning: Symbolic links are not resolved and the link file is recreated
|
| 131 |
137 |
*
|
| 132 |
138 |
* @param src the src directory
|
| 133 |
139 |
* @param dest the dest directory
|
| ... | ... | |
| 140 |
146 |
/**
|
| 141 |
147 |
* Copy files. Don't erase the destination directory and replace files if they already exists
|
| 142 |
148 |
*
|
|
149 |
* warning: Symbolic links are not resolved and the link file is recreated
|
|
150 |
*
|
| 143 |
151 |
* @param src the src directory
|
| 144 |
152 |
* @param dest the dest directory
|
| 145 |
153 |
* @param replace replace files if true
|
| ... | ... | |
| 157 |
165 |
+ "."); //$NON-NLS-1$
|
| 158 |
166 |
}
|
| 159 |
167 |
|
| 160 |
|
// is it a directory ?
|
| 161 |
|
if (src.isDirectory()) {
|
|
168 |
|
|
169 |
if (Files.isSymbolicLink(src.toPath())) { // copy symbolic links
|
|
170 |
Path target = Files.readSymbolicLink(src.toPath());
|
|
171 |
Files.createSymbolicLink(dest.toPath(), target);
|
|
172 |
} else if (src.isDirectory()) { // is it a directory ?
|
| 162 |
173 |
|
| 163 |
174 |
if (!dest.exists()) { // does the destination already exist?
|
| 164 |
175 |
// if not create the file hierarchy
|
| ... | ... | |
| 212 |
223 |
// System.out.println("delete c1 "+copy1.delete()); //$NON-NLS-1$
|
| 213 |
224 |
// System.out.println("delete c2 "+copy2.delete()); //$NON-NLS-1$
|
| 214 |
225 |
|
| 215 |
|
File dir1 = new File("/home/mdecorde/TEMP/copy1");
|
| 216 |
|
File dir2 = new File("/home/mdecorde/TEMP/copy2");
|
|
226 |
File dir1 = new File("/home/mdecorde/TEMP/copydir");
|
|
227 |
File dir2 = new File("/home/mdecorde/TEMP/copydir3");
|
| 217 |
228 |
FileCopy.copyFiles(dir1, dir2);
|
| 218 |
229 |
}
|
| 219 |
230 |
}
|