private void excludeFolderAdd_Click(object sender, RoutedEventArgs e)
        {
            using (var folderBrowser = new FolderBrowserDialog())
            {
                folderBrowser.Description = "Select a folder to exclude from check for duplicate files";

                if (folderBrowser.ShowDialog(WindowWrapper.GetCurrentWindowHandle()) != DialogResult.OK)
                {
                    return;
                }

                var excFolder = new ExcludeFolder(folderBrowser.SelectedPath);

                if (_scanBase.Options.ExcludeFolders.Contains(excFolder))
                {
                    MessageBox.Show(Application.Current.MainWindow, "The selected folder is already excluded",
                                    Utils.ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else if (_scanBase.Options.OnlySelectedFolders.GetValueOrDefault() &&
                         _scanBase.Options.IncFolders.Contains(new IncludeFolder(folderBrowser.SelectedPath)))
                {
                    MessageBox.Show(Application.Current.MainWindow,
                                    "The selected folder cannot be in both the included and excluded folders", Utils.ProductName,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    _scanBase.Options.ExcludeFolders.Add(excFolder);

                    MessageBox.Show(Application.Current.MainWindow,
                                    "The selected folder has been excluded from the search", Utils.ProductName, MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }
            }
        }
Exemple #2
0
        static int Main(string[] Args)
        {
            // Build the argument list. Remove any double-hyphens from the start of arguments for conformity with other Epic tools.
            List <string> ArgsList = new List <string>();

            foreach (string Arg in Args)
            {
                ArgsList.Add(Arg.StartsWith("--")? Arg.Substring(1) : Arg);
            }

            // Parse the parameters
            int    NumThreads = int.Parse(ParseParameter(ArgsList, "-threads=", "4"));
            int    MaxRetries = int.Parse(ParseParameter(ArgsList, "-max-retries=", "4"));
            bool   bDryRun    = ParseSwitch(ArgsList, "-dry-run");
            bool   bHelp      = ParseSwitch(ArgsList, "-help");
            string RootPath   = ParseParameter(ArgsList, "-root=", Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../..")));

            // Parse the overwrite mode
            OverwriteMode Overwrite = OverwriteMode.Unchanged;

            if (ParseSwitch(ArgsList, "-prompt"))
            {
                Overwrite = OverwriteMode.Prompt;
            }
            else if (ParseSwitch(ArgsList, "-force"))
            {
                Overwrite = OverwriteMode.Force;
            }

            // Setup network proxy from argument list or environment variable
            string ProxyUrl = ParseParameter(ArgsList, "-proxy=", null);

            if (String.IsNullOrEmpty(ProxyUrl))
            {
                ProxyUrl = Environment.GetEnvironmentVariable("HTTP_PROXY");
            }

            // Parse all the default exclude filters
            HashSet <string> ExcludeFolders = new HashSet <string>(StringComparer.CurrentCultureIgnoreCase);

            if (!ParseSwitch(ArgsList, "-all"))
            {
                if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                {
                    ExcludeFolders.Add("Win32");
                    ExcludeFolders.Add("Win64");
                }
                if (Environment.OSVersion.Platform != PlatformID.MacOSX && !(Environment.OSVersion.Platform == PlatformID.Unix && Directory.Exists("/Applications") && Directory.Exists("/System")))
                {
                    ExcludeFolders.Add("Mac");
                }
                if (Environment.GetEnvironmentVariable("EMSCRIPTEN") == null)
                {
                    ExcludeFolders.Add("HTML5");
                }
                if (Environment.GetEnvironmentVariable("NDKROOT") == null)
                {
                    ExcludeFolders.Add("Android");
                }
            }

            // Parse all the explicit include filters
            foreach (string IncludeFolder in ParseParameters(ArgsList, "-include="))
            {
                ExcludeFolders.Remove(IncludeFolder.Replace('\\', '/').Trim('/'));
            }

            // Parse all the explicit exclude filters
            foreach (string ExcludeFolder in ParseParameters(ArgsList, "-exclude="))
            {
                ExcludeFolders.Add(ExcludeFolder.Replace('\\', '/').Trim('/'));
            }

            // If there are any more parameters, print an error
            foreach (string RemainingArg in ArgsList)
            {
                Log.WriteLine("Invalid command line parameter: {0}", RemainingArg);
                Log.WriteLine();
                bHelp = true;
            }

            // Print the help message
            if (bHelp)
            {
                Log.WriteLine("Usage:");
                Log.WriteLine("   GitDependencies [options]");
                Log.WriteLine();
                Log.WriteLine("Options:");
                Log.WriteLine("   --all            Sync all folders");
                Log.WriteLine("   --include=<X>    Include binaries in folders called <X>");
                Log.WriteLine("   --exclude=<X>    Exclude binaries in folders called <X>");
                Log.WriteLine("   --prompt         Prompts for whether to overwrite modified workspace files");
                Log.WriteLine("   --force          Overwrite modified dependency files in the workspace");
                Log.WriteLine("   --root=<PATH>    Specifies the path to the directory to sync with");
                Log.WriteLine("   --threads=X      Use X threads when downloading new files");
                Log.WriteLine("   --dry-run        Print a list of outdated files, but don't do anything");
                Log.WriteLine("   --max-retries    Set the maximum number of retries for downloading files");
                Log.WriteLine("   --proxy=<URL>    Set http proxy URL");
                if (ExcludeFolders.Count > 0)
                {
                    Log.WriteLine();
                    Log.WriteLine("Current excluded folders: {0}", String.Join(", ", ExcludeFolders));
                }
                return(0);
            }

            // Register a delegate to clear the status text if we use ctrl-c to quit
            Console.CancelKeyPress += delegate { Log.FlushStatus(); };

            // Update the tree. Make sure we clear out the status line if we quit for any reason (eg. ctrl-c)
            if (!UpdateWorkingTree(bDryRun, RootPath, ExcludeFolders, NumThreads, MaxRetries, ProxyUrl, Overwrite))
            {
                return(1);
            }
            return(0);
        }