示例#1
0
        //public bool AreAllFilesRecommended()
        //{
        //    var extensions = new List<string>();
        //    string[] ignore = { ".map" };

        //    foreach (string file in Files)
        //    {
        //        string ext = Path.GetExtension(file).ToLowerInvariant();

        //        if (!ignore.Contains(ext) && !extensions.Contains(ext))
        //            extensions.Add(ext);

        //        if (extensions.Count >= 2)
        //            return true;
        //    }

        //    return false;
        //}

        internal async Task DownloadFilesAsync(string downloadDir)
        {
            if (Directory.Exists(downloadDir))
            {
                return;
            }

            var list = DownloadFiles(downloadDir, Files);

            OnDownloading(downloadDir);
            await Task.WhenAll(list);

            var remaining = AllFiles.Where(f => !Files.Contains(f));

            if (remaining.Any())
            {
                // Fire and forget to return call immediately. Download the rest of the files
                // TODO: Is there a more elegant way than using the threadpool like this?
                System.Threading.ThreadPool.QueueUserWorkItem(async(o) =>
                {
                    OnDownloadingRemainingFiles(downloadDir);

                    await Task.WhenAll(DownloadFiles(downloadDir, remaining));
                });
            }
        }
示例#2
0
        public void Filter()
        {
            // Filter all files in the directory for those satisfying the given filters
            Files.ReplaceAll(AllFiles.Where(x =>
                                            (FilterExtension == "" || x.OldExtension == FilterExtension) &&
                                            (FilterFullName ? x.OldFullName : x.OldName).RegexContains(FilterRegex ? FilterPattern : Regex.Escape(FilterPattern))));

            Preview();
        }
示例#3
0
        public override IEnumerable <string> MatchingFiles()
        {
            var allModifiedFiles = _modifiedFiles
                                   .Union(_modifiedDirectories
                                          .SelectMany(d => Directory.EnumerateFiles(d, "*.*", SearchOption.AllDirectories)))
                                   .ToHashSet();

            return(AllFiles.Where(f => allModifiedFiles.Any(m => m.ToLower().EndsWith(f.ToLower()))));
        }
示例#4
0
 private void cbShowSelectedElements_CheckedChanged(object sender, EventArgs e)
 {
     if ((sender as CheckBox).Checked)
     {
         numberedFileInfoBindingSource.DataSource = AllFiles.Where(f => f.ToDelete);
     }
     else
     {
         numberedFileInfoBindingSource.DataSource = AllFiles;
     }
 }
示例#5
0
        private List <string> FilterList(string extension)
        {
            return(AllFiles.Where(file => file.Contains(extension)).ToList());

            //var newList = new List<string>();
            //foreach (string file in AllFiles) {
            //    if (file.Contains(extension)) {
            //        newList.Add(file);
            //    }
            //}
            //return newList;
        }
        public bool CheckForMatch(string FileFullName, out Uri MatchedPath)
        {
            if (AllFiles == null)
            {
                AllFiles = Directory.GetFiles(localPath, "*", SearchOption.AllDirectories);
                AllFiles = AllFiles.Select(x => x.Replace("\\", "/")).ToArray();
            }
            var result = AllFiles.Where(x => x.Contains(FileFullName)).FirstOrDefault();

            if (result != null)
            {
                MatchedPath = new Uri(result.Replace("/", "\\"));
                return(true);
            }
            MatchedPath = null;
            return(false);
        }
示例#7
0
        private void button1_Click(object sender, EventArgs e)
        {
            var toDelete = AllFiles.Where(f => f.ToDelete);

            if (toDelete.Count() == 0)
            {
                MessageBox.Show("Il n'y a aucun fichier à supprimer");
                return;
            }

            var res = MessageBox.Show("Confirmer la suppression", $"Vous allez supprimer {toDelete.Count()} fichiers. Etes-vous sûr de vouloir continuer ?", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                foreach (var d in toDelete)
                {
                    d.Info.Delete();
                }

                DetectFiles();
            }
        }
        public override Interfaces.ConsistencyCheckResult Run()
        {
            var results = new List <Interfaces.Problem>();

            foreach (var kvp in m_bannedFilesAndReasons)
            {
                var matchingFiles = AllFiles
                                    .Where(x => Regex.IsMatch(x.Name, kvp.Key, RegexOptions.IgnoreCase))
                                    .Select(FileWithoutRootDirectory)
                                    .Select(x => new Interfaces.Problem(x, $" * {x} - {kvp.Value}"))
                                    .ToArray();

                results.AddRange(matchingFiles);
            }

            if (results.Any())
            {
                string header = "Banned files were found. Please check below for details";

                return(Interfaces.ConsistencyCheckResult.NewProblemsFound(new Interfaces.ConsistencyCheckProblem(Name, header, results.ToArray())));
            }

            return(Interfaces.ConsistencyCheckResult.Passed);
        }
示例#9
0
 /// <summary>
 /// Returns all <see cref="File"/>s of the <see cref="Project"/> matching the <paramref name="match"/> pattern.
 /// </summary>
 /// <param name="match">The match pattern.</param>
 /// <returns>Matching <see cref="File"/>s.</returns>
 public File[] FindFile(Func <File, bool> match)
 {
     return(AllFiles.Where(match).ToArray());
 }
 public override IEnumerable <string> MatchingFiles()
 {
     return(AllFiles.Where(f => _patterns.Any(p => Regex.IsMatch(f, p))));
 }
示例#11
0
 public override IEnumerable <string> MatchingFiles()
 {
     return(AllFiles.Where(f => _extensions.Any(e => e.ToLower() == Path.GetExtension(f).ToLower())));
 }