Exemplo n.º 1
0
	public static int Main (string[] args)
	{
		Dictionary<string, bool> known_files = null;
		string bundle_path = null;

		foreach (string arg in args) {

			if (arg.StartsWith("--wix=")) {
				string wix_filename = arg.Substring (6);
				try {
					XmlDocument wix_doc = new XmlDocument ();
					wix_doc.Load (wix_filename);
					known_files = GetSourcesFromDoc (wix_doc);
				} catch (XmlException e) {
					Console.WriteLine ("Invalid wix file.");
					Console.WriteLine (e);
					return 1;
				}
			} else if (arg.StartsWith ("--bundle=")) {
				bundle_path = arg.Substring (9);
				if (!Directory.Exists (bundle_path)) {
					Console.WriteLine ("Invalid bundle directory.");
					return 1;
				}
			} else {
				Console.WriteLine ("Usage: bundle-scanner --wix=<filename> --bundle=<dir>");
				return 1;
			}
		}

		if (bundle_path == null || known_files == null) {
			Console.WriteLine ("Usage: bundle-scanner --wix=<filename> --bundle=<dir>");
			return 1;
		}

		Dictionary<string, bool> ignores = new Dictionary<string, bool> ();
		if (File.Exists ("ignores")) {
			using (StreamReader rdr = new StreamReader ("ignores")) {
				while (rdr.Peek () >= 0)
					ignores [rdr.ReadLine ()] = true;
			}
		}

		BundleScanner scanner = new BundleScanner (bundle_path, known_files, ignores);
		scanner.Scan ();

		List<string> missing = scanner.ExpectedFiles;
		if (missing.Count > 0) {
			Console.WriteLine ();
			Console.WriteLine ("Expected files missing in bundle:");
			Console.WriteLine ("---------------------------");
			foreach (string file in missing)
				Console.WriteLine ("   " + file);
		}

		List<string> unexpected = scanner.UnexpectedFiles;
		if (unexpected.Count > 0) {
			Console.WriteLine ();
			Console.WriteLine ("Unexpected files in bundle:");
			Console.WriteLine ("---------------------------");
			foreach (string file in unexpected)
				Console.WriteLine ("   " + file);
		}

		return 0;
	}
Exemplo n.º 2
0
    public static int Main(string[] args)
    {
        Dictionary <string, bool> known_files = null;
        string bundle_path = null;

        foreach (string arg in args)
        {
            if (arg.StartsWith("--wix="))
            {
                string wix_filename = arg.Substring(6);
                try {
                    XmlDocument wix_doc = new XmlDocument();
                    wix_doc.Load(wix_filename);
                    known_files = GetSourcesFromDoc(wix_doc);
                } catch (XmlException e) {
                    Console.WriteLine("Invalid wix file.");
                    Console.WriteLine(e);
                    return(1);
                }
            }
            else if (arg.StartsWith("--bundle="))
            {
                bundle_path = arg.Substring(9);
                if (!Directory.Exists(bundle_path))
                {
                    Console.WriteLine("Invalid bundle directory.");
                    return(1);
                }
            }
            else
            {
                Console.WriteLine("Usage: bundle-scanner --wix=<filename> --bundle=<dir>");
                return(1);
            }
        }

        if (bundle_path == null || known_files == null)
        {
            Console.WriteLine("Usage: bundle-scanner --wix=<filename> --bundle=<dir>");
            return(1);
        }

        Dictionary <string, bool> ignores = new Dictionary <string, bool> ();

        if (File.Exists("ignores"))
        {
            using (StreamReader rdr = new StreamReader("ignores")) {
                while (rdr.Peek() >= 0)
                {
                    ignores [rdr.ReadLine()] = true;
                }
            }
        }

        BundleScanner scanner = new BundleScanner(bundle_path, known_files, ignores);

        scanner.Scan();

        List <string> missing = scanner.ExpectedFiles;

        if (missing.Count > 0)
        {
            Console.WriteLine();
            Console.WriteLine("Expected files missing in bundle:");
            Console.WriteLine("---------------------------");
            foreach (string file in missing)
            {
                Console.WriteLine("   " + file);
            }
        }

        List <string> unexpected = scanner.UnexpectedFiles;

        if (unexpected.Count > 0)
        {
            Console.WriteLine();
            Console.WriteLine("Unexpected files in bundle:");
            Console.WriteLine("---------------------------");
            foreach (string file in unexpected)
            {
                Console.WriteLine("   " + file);
            }
        }

        return(0);
    }