source: java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolFileIterator.java

Last change on this file was 1020, checked in by alloc, 10 years ago

AEI 2.22: Consider all local packages with number < 10000 as Tool, others as Mod. Repository packages are not affected by this

File size: 2.1 KB
Line 
1package net.oni2.aeinstaller.backend.oni.management.tools;
2
3import java.io.File;
4
5import net.oni2.aeinstaller.backend.CaseInsensitiveFile;
6import net.oni2.aeinstaller.backend.Paths;
7import net.oni2.aeinstaller.backend.packages.Package;
8import net.oni2.platformtools.PlatformInformation;
9import net.oni2.platformtools.PlatformInformation.Platform;
10
11/**
12 * @author Christian Illy
13 */
14public class ToolFileIterator {
15
16 /**
17 * Iterate over tool package files with source and respective target file
18 *
19 * @param tool
20 * Tool to iterate over
21 * @param handler
22 * Handler to handle found files
23 */
24 public static void iteratePlatformToolFiles(Package tool,
25 ToolFileIteratorEntry handler) {
26 File plain = CaseInsensitiveFile.getCaseInsensitiveFile(
27 tool.getLocalPath(), "plain");
28 if (plain.exists()) {
29 if (tool.hasSeparatePlatformDirs()) {
30 File plainCommon = CaseInsensitiveFile.getCaseInsensitiveFile(
31 plain, "common");
32 File plainMac = CaseInsensitiveFile.getCaseInsensitiveFile(
33 plain, "mac_only");
34 File plainWin = CaseInsensitiveFile.getCaseInsensitiveFile(
35 plain, "win_only");
36 if (plainCommon.exists())
37 iterateFiles(plainCommon, Paths.getEditionBasePath(),
38 handler);
39 if (PlatformInformation.getPlatform() == Platform.MACOS
40 && plainMac.exists())
41 iterateFiles(plainMac, Paths.getEditionBasePath(), handler);
42 else if (plainWin.exists())
43 iterateFiles(plainWin, Paths.getEditionBasePath(), handler);
44 } else {
45 iterateFiles(plain, Paths.getEditionBasePath(), handler);
46 }
47 }
48 }
49
50 private static void iterateFiles(File srcFolder, File targetFolder,
51 ToolFileIteratorEntry handler) {
52 for (File f : srcFolder.listFiles()) {
53 if (f.isDirectory()) {
54 if (f.getName().endsWith(".app")) {
55 handler.toolFile(f, new File(targetFolder, f.getName()), f.isDirectory());
56 }
57 iterateFiles(f, CaseInsensitiveFile.getCaseInsensitiveFile(
58 targetFolder, f.getName()), handler);
59 } else {
60 handler.toolFile(f, new File(targetFolder, f.getName()), f.isDirectory());
61 }
62 }
63 }
64
65}
Note: See TracBrowser for help on using the repository browser.