FileTreeCreator.java 2.0 KB
Newer Older
N
neliasso 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.util.HashSet;
import java.util.Stack;
import java.util.Vector;

public class FileTreeCreator extends SimpleFileVisitor<Path>
{
   Path vcProjLocation;
   Path startDir;
   final int startDirLength;
   Stack<DirAttributes> attributes = new Stack<DirAttributes>();
   Vector<BuildConfig> allConfigs;
   WinGammaPlatformVC10 wg;

   public FileTreeCreator(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) {
      super();
      this.wg = wg;
      this.allConfigs = allConfigs;
      this.startDir = startDir;
      startDirLength = startDir.toAbsolutePath().toString().length();
      vcProjLocation = FileSystems.getDefault().getPath(allConfigs.firstElement().get("BuildSpace"));
      attributes.push(new DirAttributes());
   }

   public class DirAttributes {

      private HashSet<BuildConfig> ignores;
      private HashSet<BuildConfig> disablePch;

      public DirAttributes() {
         ignores = new HashSet<BuildConfig>();
         disablePch = new HashSet<BuildConfig>();
      }

      public DirAttributes(HashSet<BuildConfig> excludes2, HashSet<BuildConfig> disablePch2) {
         ignores = excludes2;
         disablePch = disablePch2;
      }

      @SuppressWarnings("unchecked")
      public DirAttributes clone() {
         return new DirAttributes((HashSet<BuildConfig>)this.ignores.clone(), (HashSet<BuildConfig>)this.disablePch.clone());
      }

      public void setIgnore(BuildConfig conf) {
         ignores.add(conf);
      }

      public boolean hasIgnore(BuildConfig cfg) {
         return ignores.contains(cfg);
      }

      public void removeFromIgnored(BuildConfig cfg) {
         ignores.remove(cfg);
      }

      public void setDisablePch(BuildConfig conf) {
         disablePch.add(conf);
      }

      public boolean hasDisablePch(BuildConfig cfg) {
         return disablePch.contains(cfg);
      }

      public void removeFromDisablePch(BuildConfig cfg) {
         disablePch.remove(cfg);
      }

   }
}