public void AddStreamFile(string path, ZipArchiveEntry zipEntry, bool allowOverwrite = true)
        {
            if (GeneralInfo.JungleBlacklist.Contains(Path.GetFileName(path)))
            {
                throw new InvalidDataException(string.Format("File \"{0}\" cannot be copied to the game dir because it is blacklisted.", path));
            }

            CachedFile existing = GetCachedFile(path);

            if (existing != null)
            {
                if (existing.FileType != CachedFileType.Stream)
                {
                    throw new InvalidDataException(string.Format("File \"{0}\" is being used as both binary and xml.", path));
                }
                else
                {
                    //Exists so overwrite it.
                    existing.zipEntry = zipEntry;
                }
            }
            else
            {
                //Doesn't exist., Add it.
                cachedFiles.Add(new CachedFile(path, zipEntry, allowOverwrite));

                if (allowOverwrite)
                {
                    //Only track files if allowOverwrite is true.
                    GeneralInfo.Tracker.AddJungleFile(path);
                }
            }
        }
        private void Add(string path, object data, CachedFileType type, bool allowOverwrite = true)
        {
            var cachedFile = new CachedFile(path, data, allowOverwrite);

            if (data.GetType() == typeof(EffectContainerFile))
            {
                EffectContainerFile ecf = EffectContainerFile.New();
                ecf.AddEffects(((EffectContainerFile)data).Effects);
                cachedFile.backupEffectContainerFile = ecf;
            }
            else if (data.GetType() == typeof(ACB_File))
            {
                //Might be better to change this to a shallow-copy
                ACB_File acb = ACB_File.NewXv2Acb();

                foreach (var cue in ((ACB_File)data).Cues)
                {
                    acb.CopyCue((int)cue.ID, (ACB_File)data);
                }

                cachedFile.backupBgmFile = acb;
            }

            cachedFiles.Add(cachedFile);
        }
        /// <summary>
        /// Returns a parsed cachedFile, if it has previously been loaded. Otherwise it returns null.
        /// </summary>
        /// <returns></returns>
        public T GetParsedFile <T>(string path) where T : new()
        {
            CachedFile existing = GetCachedFile(path);

            if (existing == null)
            {
                return(default(T));
            }
            else
            {
                if (existing.FileType == CachedFileType.Parsed)
                {
                    return((T)existing.Data);
                }
                else
                {
                    //It exists but in binary form, and we are trying to load it from xml...
                    throw new InvalidDataException(string.Format("File \"{0}\" is being used as both binary and xml.", path));
                }
            }
        }
        /// <summary>
        /// Add a parsed file. Will overwrite existing files if path matches.
        /// </summary>
        public void AddParsedFile(string path, object data)
        {
            CachedFile existing = GetCachedFile(path);

            if (existing != null)
            {
                if (existing.FileType != CachedFileType.Parsed)
                {
                    throw new InvalidDataException(string.Format("File \"{0}\" is being used as both binary and xml.", path));
                }
                else
                {
                    //Exists so overwrite it.
                    existing.Data = data;
                }
            }
            else
            {
                //Doesn't exist., Add it.
                Add(path, data, CachedFileType.Parsed);
            }
        }