- Timestamp:
- Apr 7, 2015, 7:48:17 PM (10 years ago)
- Location:
- java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolFileIterator.java
r1019 r1020 19 19 * @param tool 20 20 * Tool to iterate over 21 * @param handleAppAsFiles22 * Whether or not to handle MacOS .app folders as a single file23 21 * @param handler 24 22 * Handler to handle found files 25 23 */ 26 public static void iteratePlatformToolFiles(Package tool, boolean handleAppAsFiles,24 public static void iteratePlatformToolFiles(Package tool, 27 25 ToolFileIteratorEntry handler) { 28 26 File plain = CaseInsensitiveFile.getCaseInsensitiveFile( … … 37 35 plain, "win_only"); 38 36 if (plainCommon.exists()) 39 iterateFiles(plainCommon, Paths.getEditionBasePath(), handleAppAsFiles,37 iterateFiles(plainCommon, Paths.getEditionBasePath(), 40 38 handler); 41 39 if (PlatformInformation.getPlatform() == Platform.MACOS 42 40 && plainMac.exists()) 43 iterateFiles(plainMac, Paths.getEditionBasePath(), handle AppAsFiles, handler);41 iterateFiles(plainMac, Paths.getEditionBasePath(), handler); 44 42 else if (plainWin.exists()) 45 iterateFiles(plainWin, Paths.getEditionBasePath(), handle AppAsFiles, handler);43 iterateFiles(plainWin, Paths.getEditionBasePath(), handler); 46 44 } else { 47 iterateFiles(plain, Paths.getEditionBasePath(), handle AppAsFiles, handler);45 iterateFiles(plain, Paths.getEditionBasePath(), handler); 48 46 } 49 47 } 50 48 } 51 49 52 private static void iterateFiles(File srcFolder, File targetFolder, boolean handleAppAsFiles,50 private static void iterateFiles(File srcFolder, File targetFolder, 53 51 ToolFileIteratorEntry handler) { 54 52 for (File f : srcFolder.listFiles()) { 55 if (f.isDirectory() && (!f.getName().endsWith(".app") || !handleAppAsFiles)) 53 if (f.isDirectory()) { 54 if (f.getName().endsWith(".app")) { 55 handler.toolFile(f, new File(targetFolder, f.getName()), f.isDirectory()); 56 } 56 57 iterateFiles(f, CaseInsensitiveFile.getCaseInsensitiveFile( 57 targetFolder, f.getName()), handle AppAsFiles, handler);58 else {58 targetFolder, f.getName()), handler); 59 } else { 59 60 handler.toolFile(f, new File(targetFolder, f.getName()), f.isDirectory()); 60 61 } -
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolsManager.java
r1019 r1020 26 26 final ToolInstallationList til = ToolInstallationList.getInstance(); 27 27 for (final Package m : PackageManager.getInstance().getInstalledTools()) { 28 ToolFileIterator.iteratePlatformToolFiles(m, false,28 ToolFileIterator.iteratePlatformToolFiles(m, 29 29 new ToolFileIteratorEntry() { 30 30 @Override 31 public void toolFile(File source, File target, boolean isDir) { 31 public void toolFile(File source, File target, 32 boolean isDir) { 32 33 byte[] chkSrc = FileChecksum 33 34 .calculateFileMD5(source); … … 35 36 til.markModified(m.getPackageNumber(), true); 36 37 } else { 37 byte[] chkTrg = FileChecksum 38 .calculateFileMD5(target); 39 if (!Arrays.equals(chkSrc, chkTrg)) 40 til.markModified(m.getPackageNumber(), true); 38 if (!isDir) { 39 byte[] chkTrg = FileChecksum 40 .calculateFileMD5(target); 41 if (!Arrays.equals(chkSrc, chkTrg)) 42 til.markModified(m.getPackageNumber(), true); 43 } 41 44 } 42 45 } … … 56 59 if (!uninstall) { // Install: 57 60 final HashSet<String> files = new HashSet<String>(); 58 ToolFileIterator.iteratePlatformToolFiles(m, true,61 ToolFileIterator.iteratePlatformToolFiles(m, 59 62 new ToolFileIteratorEntry() { 60 63 @Override 61 public void toolFile(File source, File target, boolean isDir) { 64 public void toolFile(File source, File target, 65 boolean isDir) { 62 66 copyToolsFiles(source, target, isDir, files); 63 67 } … … 80 84 target.getParentFile(), target.getName()); 81 85 82 files.add(target.getPath().replace( 83 Paths.getEditionBasePath().getPath(), "")); 86 if (isDir && src.getAbsolutePath().endsWith(".app")) { 87 files.add(target.getPath().replace( 88 Paths.getEditionBasePath().getPath(), "")); 84 89 85 if (isDir) {86 90 if (targetFile.exists()) { 87 91 FileUtils.deleteDirectory(targetFile); 88 92 } 89 90 FileUtils.copyDirectory(src, target, true); 93 94 FileUtils.copyDirectory(src, target, true); 91 95 } else { 92 // Case mismatch?93 if (!targetFile.getName().equals(src.getName()))94 targetFile.delete();96 if (!src.getAbsolutePath().contains(".app/")) { 97 files.add(target.getPath().replace( 98 Paths.getEditionBasePath().getPath(), "")); 95 99 96 FileUtils.copyFile(src, target); 97 if (src.canExecute()) 98 target.setExecutable(true); 100 // Case mismatch? 101 if (!targetFile.getName().equals(src.getName())) 102 targetFile.delete(); 103 104 FileUtils.copyFile(src, target); 105 } 106 107 if (src.canExecute() && targetFile.exists()) 108 targetFile.setExecutable(true); 99 109 } 100 110 } catch (IOException e) {
Note:
See TracChangeset
for help on using the changeset viewer.