1 /* 2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 package build.tools.projectcreator; 26 27 import java.nio.file.FileSystems; 28 import java.nio.file.Path; 29 import java.nio.file.SimpleFileVisitor; 30 import java.util.HashSet; 31 import java.util.Stack; 32 import java.util.Vector; 33 34 public class FileTreeCreator extends SimpleFileVisitor<Path> 35 { 36 Path vcProjLocation; 37 Path startDir; 38 final int startDirLength; 39 Stack<DirAttributes> attributes = new Stack<DirAttributes>(); 40 Vector<BuildConfig> allConfigs; 41 WinGammaPlatform wg; 42 WinGammaPlatformVC10 wg10; 43 44 public FileTreeCreator(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) { 45 super(); 46 this.wg = wg; 47 if (wg instanceof WinGammaPlatformVC10) { 48 wg10 = (WinGammaPlatformVC10)wg; 49 } 50 this.allConfigs = allConfigs; 51 this.startDir = startDir; 52 startDirLength = startDir.toAbsolutePath().toString().length(); 53 vcProjLocation = FileSystems.getDefault().getPath(allConfigs.firstElement().get("BuildSpace")); 54 attributes.push(new DirAttributes()); 55 } 56 57 public class DirAttributes { 58 59 private HashSet<BuildConfig> ignores; 60 private HashSet<BuildConfig> disablePch; 61 62 public DirAttributes() { 63 ignores = new HashSet<BuildConfig>(); 64 disablePch = new HashSet<BuildConfig>(); 65 } 66 67 public DirAttributes(HashSet<BuildConfig> excludes2, HashSet<BuildConfig> disablePch2) { 68 ignores = excludes2; 69 disablePch = disablePch2; 70 } 71 72 @SuppressWarnings("unchecked") 73 public DirAttributes clone() { 74 return new DirAttributes((HashSet<BuildConfig>)this.ignores.clone(), (HashSet<BuildConfig>)this.disablePch.clone()); 75 } 76 77 public void setIgnore(BuildConfig conf) { 78 ignores.add(conf); 79 } 80 81 public boolean hasIgnore(BuildConfig cfg) { 82 return ignores.contains(cfg); 83 } 84 85 public void removeFromIgnored(BuildConfig cfg) { 86 ignores.remove(cfg); 87 } 88 89 public void setDisablePch(BuildConfig conf) { 90 disablePch.add(conf); 91 } 92 93 public boolean hasDisablePch(BuildConfig cfg) { 94 return disablePch.contains(cfg); 95 } 96 97 public void removeFromDisablePch(BuildConfig cfg) { 98 disablePch.remove(cfg); 99 } 100 101 } 102 }