Пример #1
0
 private bool AddFiles(string[] aFiles, bool nested, Dictionary<string, ArchiveItem> seen, PartFileConsumer consumer)
 {
     var files = new List<string>(aFiles);
       return AddFiles(files, nested, seen, consumer);
 }
Пример #2
0
        private bool AddFiles(List<string> aFiles, bool nested, Dictionary<string, ArchiveItem> seen, PartFileConsumer consumer)
        {
            var added = false;
              var files = aFiles.ToArray();
              foreach (string file in files) {
            try {
              var info = new FileInfo(file);
              if (!info.Exists) {
            continue;
              }
              if ((info.Attributes & FileAttributes.Directory) == FileAttributes.Directory) {
            continue;
              }

              if (consumer.Consume(info)) {
            aFiles.Remove(file);
            continue;
              }

              var ext = info.Extension.ToUpperInvariant();
              if (seen.ContainsKey(info.FullName.ToUpperInvariant())) {
            continue;
              }

              ArchiveItem item = CreateItem(nested, info, ext);
              if (item == null) {
            continue;
              }
              seen[info.FullName.ToUpperInvariant()] = item;
              added = true;
              Files.Items.Add(item);
            }
            catch (Exception ex) {
              Console.Error.WriteLine(ex);
            }
              }
              return added;
        }
Пример #3
0
        private bool AddFiles(string[] aFiles, bool nested)
        {
            var seen = new Dictionary<string, ArchiveItem>();

              Files.BeginUpdate();
              foreach (ArchiveItem i in Files.Items) {
            seen[i.FileName.ToUpperInvariant()] = i;
              }

              var consumer = new PartFileConsumer();

              var added = AddFiles(silentFiles, nested, seen, consumer);
              added |= AddFiles(aFiles, nested, seen, consumer);
              foreach (var p in consumer.Parts) {
            var parts = p.Value;
            var files = parts.Files;
            if (!parts.HasPart(p.Key)) {
              foreach (var i in files) {
            if (!seen.ContainsKey(i.FullName.ToUpperInvariant())) {
              silentFiles.Add(i.FullName);
            }
              }
              continue;
            }

            var file = files[0];
            files.RemoveAt(0);
            ArchiveItem item;
            if (!seen.TryGetValue(file.FullName.ToUpperInvariant(), out item)) {
              item = CreateItem(nested, file);
              Files.Items.Add(item);
            }
            foreach (var i in files) {
              item.AddPart(i);
            }
            if (!parts.IsComplete) {
              item.StateImageIndex = 3;
              item.SubStatus = "Missing parts! Re-queue at your own risk!";
              item.StateImageIndex = 4;
            }
            else if (item.StateImageIndex == 4) {
              item.StateImageIndex = 3;
              item.SubStatus = "Ready...";
              item.StateImageIndex = 0;
            }
            added = true;
              }
              Files.EndUpdate();
              AdjustHeaders();
              return added;
        }