public void AppendStreamedFile(byte[] content, string fileName)
 {
     lock (mStreamArchives) {
         var availableArchive = mStreamArchives.FirstOrDefault(a => a.CanAppendFiles);
         if (availableArchive != null)
         {
             availableArchive.AddFile(fileName, content);
         }
         else
         {
             var index       = GetNextStreamingIndex();
             var archiveName = string.Format(".\\Data\\streaming\\stream_{0:D3}.mpq", index);
             var archive     = MpqArchive.CreateArchive(archiveName, 1024);
             mStreamArchives.Insert(0, archive);
         }
     }
 }
        public void AddArchive(MpqArchive archive, bool streamArchive)
        {
            var file = archive.OpenFile("(listfile)");

            if (file == IntPtr.Zero)
            {
                return;
            }

            StreamReader content;

            using (var mf = new MpqFile(file)) {
                content = new StreamReader(mf.DataStream);
            }

            var line = content.ReadLine();

            lock (mFileCache) {
                while (line != null)
                {
                    var curLine = line.Trim();
                    line = content.ReadLine();

                    var hash = curLine.ToUpperInvariant().GetHashCode();
                    if (mFileCache.ContainsKey(hash))
                    {
                        continue;
                    }

                    var entry = new Entry {
                        Name       = curLine,
                        Archive    = archive,
                        IsStreamed = streamArchive
                    };

                    mFileCache.Add(hash, entry);
                }
            }
        }