Changeset 1019 for java/installer2/src/net/oni2/aeinstaller/backend
- Timestamp:
- Mar 28, 2015, 9:07:12 PM (10 years ago)
- Location:
- java/installer2/src/net/oni2/aeinstaller/backend/oni/management
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/Installer.java
r1016 r1019 610 610 611 611 for (Package p : mods) { 612 ToolFileIterator.iteratePlatformToolFiles(p, 612 ToolFileIterator.iteratePlatformToolFiles(p, false, 613 613 new ToolFileIteratorEntry() { 614 614 @Override 615 public void toolFile(File source, File target ) {615 public void toolFile(File source, File target, boolean isDir) { 616 616 copyPlainFile(source, target, log); 617 617 } -
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolFileIterator.java
r804 r1019 19 19 * @param tool 20 20 * Tool to iterate over 21 * @param handleAppAsFiles 22 * Whether or not to handle MacOS .app folders as a single file 21 23 * @param handler 22 24 * Handler to handle found files 23 25 */ 24 public static void iteratePlatformToolFiles(Package tool, 26 public static void iteratePlatformToolFiles(Package tool, boolean handleAppAsFiles, 25 27 ToolFileIteratorEntry handler) { 26 28 File plain = CaseInsensitiveFile.getCaseInsensitiveFile( … … 35 37 plain, "win_only"); 36 38 if (plainCommon.exists()) 37 iterateFiles(plainCommon, Paths.getEditionBasePath(), 39 iterateFiles(plainCommon, Paths.getEditionBasePath(), handleAppAsFiles, 38 40 handler); 39 41 if (PlatformInformation.getPlatform() == Platform.MACOS 40 42 && plainMac.exists()) 41 iterateFiles(plainMac, Paths.getEditionBasePath(), handle r);43 iterateFiles(plainMac, Paths.getEditionBasePath(), handleAppAsFiles, handler); 42 44 else if (plainWin.exists()) 43 iterateFiles(plainWin, Paths.getEditionBasePath(), handle r);45 iterateFiles(plainWin, Paths.getEditionBasePath(), handleAppAsFiles, handler); 44 46 } else { 45 iterateFiles(plain, Paths.getEditionBasePath(), handle r);47 iterateFiles(plain, Paths.getEditionBasePath(), handleAppAsFiles, handler); 46 48 } 47 49 } 48 50 } 49 51 50 private static void iterateFiles(File srcFolder, File targetFolder, 52 private static void iterateFiles(File srcFolder, File targetFolder, boolean handleAppAsFiles, 51 53 ToolFileIteratorEntry handler) { 52 54 for (File f : srcFolder.listFiles()) { 53 if (f.isDirectory() )55 if (f.isDirectory() && (!f.getName().endsWith(".app") || !handleAppAsFiles)) 54 56 iterateFiles(f, CaseInsensitiveFile.getCaseInsensitiveFile( 55 targetFolder, f.getName()), handle r);57 targetFolder, f.getName()), handleAppAsFiles, handler); 56 58 else { 57 handler.toolFile(f, new File(targetFolder, f.getName()) );59 handler.toolFile(f, new File(targetFolder, f.getName()), f.isDirectory()); 58 60 } 59 61 } -
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolFileIteratorEntry.java
r804 r1019 14 14 * @param target 15 15 * Target of file if installed 16 * @param isFolder 17 * Is source a folder instead of a file? (MacOS .app folder) 16 18 */ 17 public void toolFile(File source, File target );19 public void toolFile(File source, File target, boolean isFolder); 18 20 } -
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolsManager.java
r804 r1019 26 26 final ToolInstallationList til = ToolInstallationList.getInstance(); 27 27 for (final Package m : PackageManager.getInstance().getInstalledTools()) { 28 ToolFileIterator.iteratePlatformToolFiles(m, 28 ToolFileIterator.iteratePlatformToolFiles(m, false, 29 29 new ToolFileIteratorEntry() { 30 30 @Override 31 public void toolFile(File source, File target ) {31 public void toolFile(File source, File target, boolean isDir) { 32 32 byte[] chkSrc = FileChecksum 33 33 .calculateFileMD5(source); … … 56 56 if (!uninstall) { // Install: 57 57 final HashSet<String> files = new HashSet<String>(); 58 ToolFileIterator.iteratePlatformToolFiles(m, 58 ToolFileIterator.iteratePlatformToolFiles(m, true, 59 59 new ToolFileIteratorEntry() { 60 60 @Override 61 public void toolFile(File source, File target ) {62 copyToolsFiles(source, target, files);61 public void toolFile(File source, File target, boolean isDir) { 62 copyToolsFiles(source, target, isDir, files); 63 63 } 64 64 }); … … 74 74 } 75 75 76 private static void copyToolsFiles(File src, File target, 76 private static void copyToolsFiles(File src, File target, boolean isDir, 77 77 HashSet<String> files) { 78 78 try { … … 80 80 target.getParentFile(), target.getName()); 81 81 82 // Case mismatch?83 if (!targetFile.getName().equals(src.getName()))84 targetFile.delete();85 86 82 files.add(target.getPath().replace( 87 83 Paths.getEditionBasePath().getPath(), "")); 88 84 89 FileUtils.copyFile(src, target); 90 if (src.canExecute()) 91 target.setExecutable(true); 85 if (isDir) { 86 if (targetFile.exists()) { 87 FileUtils.deleteDirectory(targetFile); 88 } 89 90 FileUtils.copyDirectory(src, target, true); 91 } else { 92 // Case mismatch? 93 if (!targetFile.getName().equals(src.getName())) 94 targetFile.delete(); 95 96 FileUtils.copyFile(src, target); 97 if (src.canExecute()) 98 target.setExecutable(true); 99 } 92 100 } catch (IOException e) { 93 101 e.printStackTrace(); … … 102 110 File targetFolder = targetFile.getParentFile(); 103 111 104 if (targetFile.exists()) 105 targetFile.delete(); 112 if (targetFile.exists()) { 113 if (targetFile.isDirectory()) { 114 try { 115 FileUtils.deleteDirectory(targetFile); 116 } catch (IOException e) { 117 e.printStackTrace(); 118 } 119 } else 120 targetFile.delete(); 121 } 106 122 if (targetFolder.list().length == 0) 107 123 targetFolder.delete();
Note:
See TracChangeset
for help on using the changeset viewer.