(File sourceDir, File targetDir,
long progress, long totalSize)
| 1169 | |
| 1170 | |
| 1171 | long copyDir(File sourceDir, File targetDir, |
| 1172 | long progress, long totalSize) throws IOException { |
| 1173 | // Overloaded copyDir so that the Save As progress bar gets updated when the |
| 1174 | // files are in folders as well (like in the data folder) |
| 1175 | if (sourceDir.equals(targetDir)) { |
| 1176 | final String urDum = "source and target directories are identical"; |
| 1177 | throw new IllegalArgumentException(urDum); |
| 1178 | } |
| 1179 | targetDir.mkdirs(); |
| 1180 | String[] files = sourceDir.list(); |
| 1181 | if (files != null) { |
| 1182 | for (String filename : files) { |
| 1183 | // Ignore dot files (.DS_Store), dot folders (.svn) while copying |
| 1184 | if (filename.charAt(0) == '.') { |
| 1185 | continue; |
| 1186 | } |
| 1187 | |
| 1188 | File source = new File(sourceDir, filename); |
| 1189 | File target = new File(targetDir, filename); |
| 1190 | if (source.isDirectory()) { |
| 1191 | progress = copyDir(source, target, progress, totalSize); |
| 1192 | //progressBar.setValue((int) Math.min(Math.ceil(progress * 100.0 / totalSize), 100)); |
| 1193 | setProgress((int) (100L * progress / totalSize)); |
| 1194 | target.setLastModified(source.lastModified()); |
| 1195 | } else { |
| 1196 | copyFile(source, target, progress, totalSize); |
| 1197 | progress += source.length(); |
| 1198 | //progressBar.setValue((int) Math.min(Math.ceil(progress * 100.0 / totalSize), 100)); |
| 1199 | setProgress((int) (100L * progress / totalSize)); |
| 1200 | } |
| 1201 | } |
| 1202 | } else { |
| 1203 | throw new IOException("Could not list files inside " + sourceDir); |
| 1204 | } |
| 1205 | return progress; |
| 1206 | } |
| 1207 | |
| 1208 | |
| 1209 | @Override |
no test coverage detected